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; }
相关推荐
"rate-my-landlords" 是一个项目名称,很可能是一个在线平台或应用,旨在帮助租客对他们的房东进行评价和分享租房经验。这个项目基于 TypeScript 开发,TypeScript 是 JavaScript 的超集,提供静态类型系统、类和...
【标题解析】: "Landlords.rar" 这个文件名暗示了这是一个关于“地主”游戏,也就是我们熟知的斗地主游戏的源代码。".rar" 是一个压缩文件格式,通常用于打包和分发多个相关文件。结合描述中的 "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
**Laravel 开发与 Kefu5 集成** 在 Laravel 开发中,Kefu5 或 kf5 是一个常见的客服系统,它提供了一套RESTful API接口,便于开发者将其集成到自己的Web应用中,特别是基于 Laravel 框架的应用。...
在"斗地主残局算法python"的压缩包文件WeChat_LandLords-master中,可能包含了实现以上功能的Python源代码文件、测试用例、数据结构定义以及可能的注释和文档。通过阅读和理解这些代码,我们可以学习如何将复杂的...
《网络版联机斗地主游戏资源解析与技术要点》 网络版的联机斗地主游戏,作为一款深受玩家喜爱的多人在线竞技游戏,其开发技术和实现方式一直是许多开发者关注的焦点。"doudizhu.rar"这个压缩包文件就提供了一款全网...
#Home For Humanity ###Introduction 积极的房东-租户关系始于申请流程。 潜在租户可以通过在查询列表时包含个人资料链接来给人留下良好的第一印象。 Home for Human 是一个 Web 应用程序,用于根据基于图像的个性...
absent也可以作为名词,表示不在者或旷工人员,如absentee landlords(在外地主)等。例如:“He was absent from the meeting.”(他今天开会缺席。) 再者,让我们来看absenteeism这个词汇。absenteeism表示经常...
宁巴尼大地主 Nyumbani是斯瓦希里语,意为家。 该系统旨在解决财产使用权期间面临的当前挑战,因此旨在成为财产管理解决方案。 关于 Nyumbani物业管理器是一个系统,可以让您以数字方式管理您的物业。...
在IT行业中,数据库管理和SQL(Structured Query Language)是至关重要的技术领域,特别是在处理大量结构化数据时。"银行-支行数据的sql文件"提供了一种高效的方式来存储、管理和分析银行分支网络的相关信息。...
这个课程设计的核心是实现斗地主游戏中的发牌功能,通过编写Player类和Landlords类来模拟游戏流程。 Player类是用于表示游戏中的玩家角色,包含以下关键知识点: 1. **属性**:Player类定义了三个属性,分别是玩家...
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...
`order-motion` 是一个基于 jQuery 的插件,主要用于在网页元素上按照预设的顺序添加类,从而实现一系列动态效果。这个插件的核心功能是帮助开发者控制元素的动画顺序,使得网页交互更加流畅且具有视觉吸引力。...
在本例中,`landlords.jar`是这个游戏的主程序文件,用户只需双击即可启动游戏。 斗地主是一种流行的三人扑克牌游戏,Java实现的斗地主游戏通常会包含以下几个核心知识点: 1. **图形用户界面(GUI)**:Java的...
文件名称“Landlords-master”可能是指斗地主项目的主分支,通常在版本控制系统如Git中,master分支代表项目的主线开发。这个文件夹可能包含了项目的源代码、资源文件、配置文件等,开发者可以通过解压这个zip文件来...
在IT行业中,"appInstall"通常指的是安装应用的过程,尤其是针对移动设备如智能手机和平板电脑。这个过程可以涉及从各种来源获取应用程序,如应用商店、官方网站或其他第三方平台。以下是一些关于下载和安装应用程序...
【Landlords - V2022.3.8.rar】是游戏的源代码文件,包含游戏的核心算法和界面代码。通过阅读和分析源代码,学习者可以深入理解如何在QT中实现游戏逻辑,如何与数据库交互,以及如何优化性能和用户体验。 【cpp...