Fighting the Landlords
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 552 Accepted Submission(s): 193
Problem Description
Fighting the Landlords is a card game which has been a heat for years in China. The game goes with the 54 poker cards for 3 players, where the “Landlord” has 20 cards and the other two (the “Farmers”) have 17. The Landlord wins if he/she has no cards left, and the farmer team wins if either of the Farmer have no cards left. The game uses the concept of hands, and some fundamental rules are used to compare the cards. For convenience, here we only consider the following categories of cards:
1.Solo: a single card. The priority is: Y (i.e. colored Joker) > X (i.e. Black & White Joker) > 2 > A (Ace) > K (King) > Q (Queen) > J (Jack) > T (10) > 9 > 8 > 7 > 6 > 5 > 4 > 3. It’s the basic rank of cards.
2.Pair : two matching cards of equal rank (e.g. 3-3, 4-4, 2-2 etc.). Note that the two Jokers cannot form a Pair (it’s another category of cards). The comparison is based on the rank of Solo, where 2-2 is the highest, A-A comes second, and 3-3 is the lowest.
3.Trio: three cards of the same rank (e.g. 3-3-3, J-J-J etc.). The priority is similar to the two categories above: 2-2-2 > A-A-A > K-K-K > . . . > 3-3-3.
4.Trio-Solo: three cards of the same rank with a Solo as the kicker. Note that the Solo and the Trio should be different rank of cards (e.g. 3-3-3-A, 4-4-4-X etc.). Here, the Kicker’s rank is irrelevant to the comparison, and the Trio’s rank determines the priority. For example, 4-4-4-3 > 3-3-3-2.
5.Trio-Pair : three cards of the same rank with a Pair as the kicker (e.g. 3-3- 3-2-2, J-J-J-Q-Q etc.). The comparison is as the same as Trio-Solo, where the Trio is the only factor to be considered. For example,4-4-4-5-5 > 3-3-3-2-2. Note again, that two jokers cannot form a Pair.
6.Four-Dual: four cards of the same rank with two cards as the kicker. Here, it’s allowed for the two kickers to share the same rank. The four same cards dominates the comparison: 5-5-5-5-3-4 > 4-4-4-4-2-2.
In the categories above, a player can only beat the prior hand using of the same category but not the others. For example, only a prior Solo can beat a Solo while a Pair cannot. But there’re exceptions:
7.Nuke: X-Y (JOKER-joker). It can beat everything in the game.
8.Bomb: 4 cards of the same rank. It can beat any other category except Nuke or another Bomb with a higher rank. The rank of Bombs follows the rank of individual cards: 2-2-2-2 is the highest and 3-3-3-3 is the lowest.
Given the cards of both yours and the next player’s, please judge whether you have a way to play a hand of cards that the next player cannot beat you in this round. If you no longer have cards after playing, we consider that he cannot beat you either. You may see the sample for more details.
1.Solo: a single card. The priority is: Y (i.e. colored Joker) > X (i.e. Black & White Joker) > 2 > A (Ace) > K (King) > Q (Queen) > J (Jack) > T (10) > 9 > 8 > 7 > 6 > 5 > 4 > 3. It’s the basic rank of cards.
2.Pair : two matching cards of equal rank (e.g. 3-3, 4-4, 2-2 etc.). Note that the two Jokers cannot form a Pair (it’s another category of cards). The comparison is based on the rank of Solo, where 2-2 is the highest, A-A comes second, and 3-3 is the lowest.
3.Trio: three cards of the same rank (e.g. 3-3-3, J-J-J etc.). The priority is similar to the two categories above: 2-2-2 > A-A-A > K-K-K > . . . > 3-3-3.
4.Trio-Solo: three cards of the same rank with a Solo as the kicker. Note that the Solo and the Trio should be different rank of cards (e.g. 3-3-3-A, 4-4-4-X etc.). Here, the Kicker’s rank is irrelevant to the comparison, and the Trio’s rank determines the priority. For example, 4-4-4-3 > 3-3-3-2.
5.Trio-Pair : three cards of the same rank with a Pair as the kicker (e.g. 3-3- 3-2-2, J-J-J-Q-Q etc.). The comparison is as the same as Trio-Solo, where the Trio is the only factor to be considered. For example,4-4-4-5-5 > 3-3-3-2-2. Note again, that two jokers cannot form a Pair.
6.Four-Dual: four cards of the same rank with two cards as the kicker. Here, it’s allowed for the two kickers to share the same rank. The four same cards dominates the comparison: 5-5-5-5-3-4 > 4-4-4-4-2-2.
In the categories above, a player can only beat the prior hand using of the same category but not the others. For example, only a prior Solo can beat a Solo while a Pair cannot. But there’re exceptions:
7.Nuke: X-Y (JOKER-joker). It can beat everything in the game.
8.Bomb: 4 cards of the same rank. It can beat any other category except Nuke or another Bomb with a higher rank. The rank of Bombs follows the rank of individual cards: 2-2-2-2 is the highest and 3-3-3-3 is the lowest.
Given the cards of both yours and the next player’s, please judge whether you have a way to play a hand of cards that the next player cannot beat you in this round. If you no longer have cards after playing, we consider that he cannot beat you either. You may see the sample for more details.
Input
The input contains several test cases. The number of test cases T (T<=20) occurs in the first line of input.
Each test case consists of two lines. Both of them contain a string indicating your cards and the next player’s, respectively. The length of each string doesn’t exceed 17, and each single card will occur at most 4 times totally on two players’ hands except that the two Jokers each occurs only once.
Each test case consists of two lines. Both of them contain a string indicating your cards and the next player’s, respectively. The length of each string doesn’t exceed 17, and each single card will occur at most 4 times totally on two players’ hands except that the two Jokers each occurs only once.
Output
For each test case, output Yes if you can reach your goal, otherwise output No.
Sample Input
4
33A
2
33A
22
33
22
5559T
9993
Sample Output
Yes
No
Yes
Yes
题意:
给出 T(<= 20) 组数据,每组数据给出两副牌,判断能不能一把牌就让对方出不到牌,如果自己出完也算赢。能则输出 yes,不能则输出 no。
思路:
模拟。
AC:
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef struct { int one_max, two_max; int three_max, four_max; int one, two, three, four; int card[20]; int ans; } node; void change (char *s, node *a) { int len = strlen(s); for (int i = 0; i < len; ++i) { int k; if (s[i] == '3') k = 1; if (s[i] == '4') k = 2; if (s[i] == '5') k = 3; if (s[i] == '6') k = 4; if (s[i] == '7') k = 5; if (s[i] == '8') k = 6; if (s[i] == '9') k = 7; if (s[i] == 'T') k = 8; if (s[i] == 'J') k = 9; if (s[i] == 'Q') k = 10; if (s[i] == 'K') k = 11; if (s[i] == 'A') k = 12; if (s[i] == '2') k = 13; if (s[i] == 'X') k = 14; if (s[i] == 'Y') k = 15; if (!a -> card[k]) ++a -> ans; a -> card[k]++; } for (int i = 1; i <= 15; ++i) { if (a -> card[i] == 1) { ++a -> one; a -> one_max = max(a -> one_max, i); } else if (a -> card[i] == 2) { ++a -> two; a -> two_max = max(a -> two_max, i); } else if (a -> card[i] == 3) { ++a -> three; a -> three_max = max(a -> three_max, i); } else if (a -> card[i] == 4) { ++a -> four; a -> four_max = max(a -> four_max, i); } } } bool one_time (node a) { if (a.card[14] && a.card[15]) return true; if (a.ans == 1) return true; if (a.ans == 2) { if (a.four && a.one == 2) return true; if (a.four && a.two) return true; if (a.three && a.two) return true; if (a.three && a.one) return true; } return false; } int main() { int t; scanf("%d", &t); while (t--) { char A[20], B[20]; node p[5]; memset(p, 0, sizeof(p)); scanf("%s%s", A, B); change(A, &p[1]); change(B, &p[2]); if (one_time(p[1])) printf("Yes\n"); //一次出完全部 else if (p[2].card[14] && p[2].card[15]) printf("No\n"); else if (p[1].four && !p[2].four) printf("Yes\n"); else if (!p[1].four && p[2].four) printf("No\n"); else if (p[1].four_max > p[2].four_max) printf("Yes\n"); else if (p[1].four_max < p[2].four_max) printf("No\n"); //炸情况 else if (p[1].three && !p[2].three) printf("Yes\n"); else if (p[1].three_max > p[2].three_max) printf("Yes\n"); //三张牌情况 else if (p[2].three && p[1].two_max > p[2].two_max && p[1].two_max > p[2].three_max) printf("Yes\n"); else if (!p[2].three && p[1].two_max > p[2].two_max) printf("Yes\n"); //两张牌情况 else if (p[2].two && p[2].three && p[1].one_max > p[2].one_max && p[1].one_max > p[2].two_max && p[1].one_max > p[2].three_max) printf("Yes\n"); else if (p[2].two && !p[2].three && p[1].one_max > p[2].one_max && p[1].one_max > p[2].three_max) printf("Yes\n"); else if (!p[2].two && p[2].three && p[1].one_max > p[2].one_max && p[1].one_max > p[2].three_max) printf("Yes\n"); else if (!p[2].two && !p[2].three && p[1].one_max > p[2].one_max) printf("Yes\n"); else printf("No\n"); } return 0; }
相关推荐
评价我的房东
JAVA源码
In response to this airbnb data, the business problem we are going to solve is "how to let airbnb landlords get higher profits". Based on our business problems, we will analyze what factors affect the...
房东 此应用程序托管在Heroku域上: : 示例: : 入门 技术栈 节点 NestJS 邮递区号 要引导应用程序,您可以通过docker docker-compose up -d运行docker-compose.yml文件。 该应用程序同时支持REST和GraphQL
包含各类银行的支行数据,2021年数据,自己使用过,算是比较全的了
Laravel开发-laravel-kefu5 用于Laravel 5.1/5.2的kefu5/kf5 restful API
网络版 联机斗地主 全网首发 比网上其他乱七八糟的资源好100倍 游戏资源是网络搬运的 内涵使用说明 js编写简单易懂 代码内只支持10个房间的自动部署游戏 可以自行修改
#Home For Humanity ###Introduction 积极的房东-租户关系始于申请流程。 潜在租户可以通过在查询列表时包含个人资料链接来给人留下良好的第一印象。 Home for Human 是一个 Web 应用程序,用于根据基于图像的个性...
宁巴尼大地主 Nyumbani是斯瓦希里语,意为家。 该系统旨在解决财产使用权期间面临的当前挑战,因此旨在成为财产管理解决方案。 关于 Nyumbani物业管理器是一个系统,可以让您以数字方式管理您的物业。...
Ratel 项目介绍 Project ...接下来,运行 landlords-client 和 landlords-server 的 target 文件夹下的Jar包: java -jar landlords-server/target/landlords-server-#{version}.jar -p 1024 java -jar land
将项目目录中的资源文件resource.rcc拷贝到生成的build目录下即可,build 目录名示例:build-Landlords-Desktop_Qt_5_15_2_MinGW_32_bit-Debug 直接双击.exe可执行文件启动程序 将项目目录中的资源文件resource....
将项目目录中的资源文件resource.rcc拷贝到生成的build目录下即可,build 目录名示例:build-Landlords-Desktop_Qt_5_15_2_MinGW_32_bit-Debug 直接双击.exe可执行文件启动程序 将项目目录中的资源文件resource.rcc...
命令-运动 按指定顺序添加类 例子 var orderMotion = new orderMotion ( { interval : 300 } ) ;
appInstall 下载app
java版斗地主源码 斗地主游戏 version 2.0 说明文档 升级说明: 采用面向对象编程,理解子类与父类的关系,成员变量及类内方法的继承,父类方法的重写。...com.kris.landlords; /** * 主程序 * * @author: Kris *