时间限制:1000ms

单点时限:1000ms

内存限制:256MB

描述

Cheat is a card game played by four players sitting around a table. They are numbered from 1 to 4 in clockwise order.

A pack of 52 cards is used. There are 13 ranks from low to high: A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, and four cards for each rank. At the beginning, each player gets 13 cards in hand randomly. The first player who discards all his cards is the winner.

The game consists of multiple rounds.

In each round: At first, a player, let's call him as a "round holder", put down some face-down cards on the table and makes a statement about the rank of those cards (such as "These are two Qs") . In a statement, all cards are of the same rank. Round holder can lie if he wants to. Then, other players will decide whether to challenge the statement in turn according to clockwise order. If nobody challenges, this round ends and the cards remains on the table. If somebody challenges, the cards put down by the round holder will be revealed. If the statement is true, the challenger takes back all cards on the table, and this round ends. If the statement is a lie, the round holder takes back all cards on the table, and this round also ends.

Player 1 is the first round holder. And players take turns to be the round holder according to clockwise order until someone wins. The first round holder must state that the cards he put down on the table are all rank A. Other statements must be exactly one rank higher than the previous statement (But rank K is followed by rank A). If a round holder has no cards of the required rank, he has to lie.

The first player who empty his hand at the end of a round is the winner.

Assume players played with the following strategies:

Player 1:

1.    When being the round holder, he always makes a true statement and put down one card of the required rank if he can. If he can't, he always put down one card with the minimum lexicographic rank order. (10<2<3<…<9<A<J<K<Q)

2.    Challenge the round holder if he is the next round holder and he has to lie in the next round.

3.    Challenge the round holder if the round holder states that he put down p cards of rank X, and player 1 has q cards of rank X in his hand, and p+q>4.

Player 2:

1.    When being the round holder, he always makes a true statement and put down all cards of the required rank if he can. If he can't, he always put down one card with the minimum lexicographic rank order. (10<2<3<…<9<A<J<K<Q)

2.    Challenge the round holder if and only if he is the next round holder and he has to lie in the next round.

Player 3:

1.    When being the round holder, he always makes a true statement and put down all cards of the required rank if he can. If he can't, he always put down all cards of a rank whose number of cards is the minimum in his hand. If there are multiple choices, choose the cards with the minimum lexicographic order. (10<2<3<…<9<A<J<K<Q)

2.    Challenge the statement if and only if he has all 4 cards of the stated rank in his hand.

Player 4:

1.    When being the round holder, always put down all cards of the required rank if he has three or four of them. Otherwise, always put down all cards of the required rank (if any) along with one more card (if any) with the minimum lexicographic order. (10<2<3<…<9<A<J<K<Q)

2.    Challenge the round holder if and only if the round holder has already emptied his hand.

Given the cards each player has at the beginning,  could you please figure out the cards in each player's hand when the game ends?

输入

There are no more than 100 test cases.

For each test case:

Four lines, indicating the cards in player 1, 2, 3 and 4 respectively.

Each line contains 13 strings separated by white space, indicating the rank of each card.

It is guaranteed that the given 52 cards form a pack.

输出

For each test case:

Output four lines, each line has multiple strings separated by white space, indicating the cards in each player's hand ordered by rank. The line for the winner is "WINNER". It is guaranteed that there are at most 1000 rounds each game.

样例输入

A 2 3 4 5 6 7 8 9 10 J Q K
A 2 3 4 5 6 7 8 9 10 J Q K
A 2 3 4 5 6 7 8 9 10 J Q K
A 2 3 4 5 6 7 8 9 10 J Q K
K A A A 5 5 5 5 9 9 9 9 K
A 2 2 2 2 6 6 6 6 10 10 10 10
3 3 3 3 7 7 7 7 J J J J K
4 4 4 4 8 8 8 8 Q Q Q Q K

样例输出

2 6 7 10 J
3 7 8 J Q
4 8 9 Q K
WINNER
A A 5 5 5 9 9 9 K
WINNER
K
A A 2 2 2 2 3 3 3 3 4 4 4 4 5 6 6 6 6 7 7 7 7 8 8 8 8 9 10 10 10 10 J J J J Q Q Q Q K K
#include<bits/stdc++.h>
using namespace std;typedef long long LL;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define per(i,a,b) for(int i=b-1;i>=a;--i)int P[5][20];
int num[5];struct Node {int id,num;Node(int _id=0,int _num=0){id=_id,num=_num;}
};vector<Node> vec;
vector<Node> desk;int arr[]={10,2,3,4,5,6,7,8,9,1,11,13,12};
int dele(int hold,int v)
{int ans=-1;rep(i,0,13){int t=arr[i];if(!P[hold][t])continue;ans=t;P[hold][t]--;num[hold]--;vec.push_back(Node(t,1));desk.push_back(Node(t,1));break;}return ans;
}void dele_num(int hold)
{int ans=14,pos=-1;rep(i,0,13){int t=arr[i];if(P[hold][t]&&P[hold][t]<ans){ans=P[hold][t];pos=t;}}vec.push_back(Node(pos,P[hold][pos]));desk.push_back(Node(pos,P[hold][pos]));num[hold]-=P[hold][pos];P[hold][pos]=0;
}int is_true(int hold,int nw)
{if(hold==0||hold==1||hold==2) {return P[hold][nw]>=1;} else {return P[hold][nw]>=3;}
}int is_ok1(int nw)
{int res=0;rep(i,0,vec.size()) {Node& a=vec[i];res+=a.num;}return res+P[0][nw]>4;
}int is_ok2(int nw)
{return P[2][nw]==4;
}int is_ok3(int hold)
{return num[hold]==0;
}int Challenge(int hold,int id,int wrong)
{int sz=desk.size();if(wrong) {rep(i,0,sz) {Node& a=desk[i];P[hold][a.id]+=a.num;num[hold]+=a.num;}desk.clear();return 1;} else {rep(i,0,sz) {Node& a=desk[i];P[id][a.id]+=a.num;num[id]+=a.num;}desk.clear();return 0;}
}char str[15][3]={"","A","2","3","4","5","6","7","8","9","10","J","Q","K"};
void show()
{for(int i=0; i<4; i++) {int flag=0;if(!num[i]) {printf("WINNER");} else {rep(j,1,14) {if(!P[i][j])continue;for(int k=1; k<=P[i][j]; k++) {if(flag)     printf(" %s",str[j]);else {flag=1;printf("%s",str[j]);}}}}printf("\n");}
}int change_id(int hold,int id,int nw,int nee,int wrong)
{if(id==0){if((hold==3&&!P[0][nee])||is_ok1(nw)) {return Challenge(hold,0,wrong);}return 0;}else if(id==1){if(hold==0&&!P[1][nee]) {return Challenge(hold,1,wrong);}return 0;}else if(id==2){if(hold!=2&&is_ok2(nw)) {return Challenge(hold,2,wrong);}return 0;}else if(id==3){if(hold!=3&&is_ok3(hold)) {return Challenge(hold,3,wrong);}return 0;}return 0;
}
/*
1.态度问题 不要缩略着读题,尤其是那个K和Q的顺序,不要总是以为考虑到一个点,就觉得很牛逼,要谦虚,冷静。
2.写的时候 考虑细节,也就是各种分支和极限情况
3.清楚定义 知道自己写的到底是什么意思
4.考虑循环 循环的开始和结尾
5.要怀疑自己,不要认为自己很对,想不出来了,相信自己,肯定能做出来的
6.注意返回值,不要随机,上面的函数就是忘了一些函数的返回值
*/map<string,int> D;
int main()
{D["A"]=1,D["2"]=2,D["3"]=3,D["4"]=4,D["5"]=5,D["6"]=6,D["7"]=7,D["8"]=8,D["9"]=9,D["10"]=10,D["J"]=11,D["Q"]=12,D["K"]=13;// freopen("456.txt","w",stdout);char ch[10];while(scanf("%s",&ch)==1) {rep(i,0,5)rep(j,0,20)P[i][j]=0;P[0][D[ch]]++;rep(i,0,12) {scanf("%s",&ch);P[0][D[ch]]++;}rep(i,1,4) {rep(j,0,13) {scanf("%s",&ch);P[i][D[ch]]++;}}desk.clear();num[0]=num[1]=num[2]=num[3]=13;int hold=0,nw=1,wrong=-1;while(1) {vec.clear();if(is_true(hold,nw)) {wrong=0;if(hold==0) {P[hold][nw]--;num[hold]--;vec.push_back(Node(nw,1));desk.push_back(Node(nw,1));} else {num[hold]-=P[hold][nw];vec.push_back(Node(nw,P[hold][nw]));desk.push_back(Node(nw,P[hold][nw]));P[hold][nw]=0;}} else {wrong=1;if(hold==0||hold==1) {int res=dele(hold,1);} else if(hold==2) {dele_num(hold);//删除最小数量,最小字典序的字符} else if(hold==3) {num[hold]-=P[hold][nw];if(P[hold][nw]) {vec.push_back(Node(nw,P[hold][nw]));desk.push_back(Node(nw,P[hold][nw]));}//  printf("%d****num:%d\n",P[hold][nw],num[3]);P[hold][nw]=0;int res=dele(hold,1);if(res==-1)wrong=0;//  printf("num:%d\n",num[3]);}}int nee=nw+1;if(nee==14)nee=1;//printf("hold:%d\n",hold);for(int i=0; i<4; ++i) {int id=(hold+i)%4;if(id==hold)continue;//printf("id:%d\n",id);if(change_id(hold,id,nw,nee,wrong))break;}int out=0;for(int i=0; i<4; i++) {if(!num[i]) {out=1;break;}}// printf("\n");if(out)break;// printf("******\n");//show();hold=(hold+1)%4;nw++;if(nw==14)nw=1;}show();}return 0;
}

#1830 : Cheat相关推荐

  1. HihoCoder 1830 Cheat ICPC2018 北京网络赛

    //写完和贴吧群dalao的代码比了一下 结果发现总是有更好的写法让你规避bug - -郁闷https://paste.ubuntu.com/p/8RRBw7jrHQ/ #include <bi ...

  2. cheat engine lua

    function CEButton1Click(sender) local x = getProperty(CETrainer.CEEdit1,"Text")--这句很重要,获取文 ...

  3. 数据科学+python+R+数据库+机器学习+(速查表)cheat sheets大全

    数据科学+python+R+数据库+机器学习+(速查表)cheat sheets大全 Learn, compete, hack and get hired! 学习.竞争.精进.996. 东西永远学不完 ...

  4. Cheat—— 给Linux初学者和管理员一个终极命令行备忘单

    当你不确定你所运行的命令,尤其是那些使用了许多选项的复杂命令时,你会怎么做?在这种情况下,我们使用man pages来获取帮助.还有一些其它的选择可能包括像'help','whereis'和'what ...

  5. Linux下更好用的帮助命令—cheat

    导读 Linux系统中,我们经常会用man命令来帮助查看这个命令的具体用法,man是很强大的,但是英语不好的同学用man用起来可能不那么顺手,自然而然的就出现了cheat命令,cheat命令就是通过简 ...

  6. Cheat Engine Tutorial 闯关手记

    Cheat Engine Tutorial 闯关手记 第一关 Cheat Engine 能做什么?修改游戏的数值,就象<金山游侠V>,但它能胜任动态地址的查找:制作游戏专用的修改器,补丁, ...

  7. cheat.sh 在手,天下我有

    点击上方蓝色"程序猿DD",选择"设为星标" 回复"资源"获取独家整理的学习资料! 前言 作为程序员需要了解的东西有很多,日常编码和写脚本脱 ...

  8. bzoj2806: [Ctsc2012]Cheat

    地址:http://www.lydsy.com/JudgeOnline/problem.php?id=2806 题目: 2806: [Ctsc2012]Cheat Time Limit: 20 Sec ...

  9. 利用cheat engine以及VC编写游戏修改器

    cheat engine的介绍已经完毕了,下面就是怎么使用它的问题,这里写一个稍微有意思一点的,也有实际用途的话题,就是来编写自己的游戏修改器. 这篇文章参考了http://www.pediy.com ...

最新文章

  1. 创业3年!猎头加价50%!一半中层骨干被挖走,研发就剩2个应届生!绝户套餐真够狠的!...
  2. EOS之记事本智能合约
  3. mysql导出 error1290_解决MySQL导出数据到文件报错:ERROR 1290
  4. Set Up Optimization
  5. python算法实现源码_Python实现七个基本算法
  6. vscode卸载background插件_萌妹程序员鼓励师24小时在线陪你写代码,给我吹爆这个VSCode插件...
  7. C/C++基础语法复习(三):C++重载函数,多态,虚函数
  8. 2699!Redmi Note 11潮流限定版再次发售:全球首发“全系悬浮工艺”
  9. Docker的Hadoop-Hbase的 Docker Hub文档
  10. 《企业软件交付:敏捷与高效管理精要》——2.5 项目执行结果
  11. 《人工智能》之《计算智能》习题解析
  12. Cesium 生成和加载离线地形
  13. 用C#实现自定义列表_艾孜尔江撰
  14. 路飞学城python全栈开发_[Python] 老男孩路飞学城Python全栈开发重点班 骑士计划最新100G...
  15. 解决python同时执行多个程序的方案
  16. 深信服终端检测响应平台EDR-远程命令执行漏洞
  17. 怎么调试S12X微控制器的XGATE上的软件
  18. java编程技术交流
  19. SSM基于WEB的房屋出租管理系统 毕业设计-附源码261620
  20. 【开源共享】全网最简单易用的imx6ull烧写工具设计初衷工作原理设计前的思考

热门文章

  1. 一场属于HTML5守望者的盛宴——记图灵参加HTML5峰会
  2. 信息学奥赛C++语言: 整理药名
  3. 强烈推荐 DELPHI 程序员用 KOL+MCK
  4. 什么是RMI,什么是RPC,两者之间的区别是什么?
  5. 五脏有问题,该怎么调理?
  6. 如何在电脑使用计算机,Windows To Go 如何在电脑上使用?
  7. 百度语音识别vs科大讯飞语音识别
  8. python(7) - 发送、接收电子邮件
  9. 旅游流的概念_旅游流
  10. 有没有测试鼠标是否丢帧的软件,深澜大叔教你如何准确检测鼠标是否丢帧