题目链接:

pid=4930">http://acm.hdu.edu.cn/showproblem.php?

pid=4930

Fighting the Landlords

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)

Total Submission(s): 546 Accepted Submission(s): 188

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, theKicker’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 youin 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, andeach 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
Author
BUPT
Source

题目意思:

两个人设为A和B,A和B在打斗地主,上面一行是A手里的牌,以下一行是B手里的牌,若A第一次出牌B压不住或者A一次就把牌出完了。那么输出Yes,否则若A牌没出完并且被B压住了那么输出No。

代码例如以下:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define M 26
char s1[M], s2[M];
int c1[M], c2[M];
int a1[M], a2[M];
int b1[M], b2[M];
int len1, len2;
int max(int a, int b)
{
return a > b ? a:b;
} void init()
{
memset(a1,0,sizeof(a1));
memset(b1,0,sizeof(b1));
memset(a2,0,sizeof(a1));
memset(b2,0,sizeof(b2));
memset(c1,0,sizeof(c1));
memset(c2,0,sizeof(c2));
}
int f(char c)
{
if(c >= '3' && c <= '9')
return c -'2';
if(c == 'T')
return 8;
if(c == 'J')
return 9;
if(c == 'Q')
return 10;
if(c == 'K')
return 11;
if(c == 'A')
return 12;
if(c == '2')
return 13;
if(c == 'X')
return 14;
if(c == 'Y')
return 15;
}
void Find(int *c, int flag)
{
int i;
int a[6], b[6];
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
for(i = 1; i <= 13; i++)
{
if(c[i])
{
b[1] = max(b[1],i);
if(c[i] == 1)//单张
{
a[1]++;
}
else if(c[i] == 2)//对子
{
a[2]++;
b[2] = max(b[2],i);
}
else if(c[i] == 3)//三个的
{
a[3]++;
b[3] = max(b[3],i);
}
else if(c[i] == 4)//炸弹
{
a[4]++;
b[4] = max(b[4],i);
}
}
}
if(c[14] && c[15])//双王
{
b[1] = 15;
a[5]++;
}
else if(c[15])//大王
{
b[1] = 15;
}
else if(c[14])//小王
{
b[1] = 14;
} for(i = 1; i <= 5; i++)
{
if(flag == 1)
{
a1[i] = a[i];
b1[i] = b[i];
}
else if(flag == 2)
{
a2[i] = a[i];
b2[i] = b[i];
}
}
}
void solve()
{
int i, j;
int flag1, flag2;
int n1=strlen(s1);
int n2=strlen(s2);
if((n1==1)||(n1==2&&a1[2])||(n1==3&&a1[3])||(n1==4&&(a1[4]||a1[3]))||(n1==5&&a1[2]&&a1[3])||(n1==6&&a1[2]&&a1[4]))
{
printf("Yes\n");//一次出完
}
else if(a1[5])
{
printf("Yes\n"); //A手里有王炸
}
else if(a2[5])
{
printf("No\n"); //B手里有王炸
}
else if(b1[4]>b2[4])
{
printf("Yes\n"); //A手里的炸弹比B手里的炸弹大
}
else if(b1[4]<b2[4]) //反之
{
printf("No\n");
}
else if(b1[1]>b2[1]) //出单,且单比B的大
{
printf("Yes\n");
}
else if(b1[2]>b2[2]) //出对,且对照B的大
{
printf("Yes\n");
}
else if(b1[3]&&(b1[3]>b2[3]||(b1[1]&&!b2[1])||(b1[2]&&!b2[2])))
{ //出3张时,能够带1张也能够带2张也能够不带。依次推断
printf("Yes\n");
}
else
{
printf("No\n");
}
}
int main()
{
int t;
int i, j;
scanf("%d",&t);
while(t--)
{
init();
scanf("%s",s1);
scanf("%s",s2);
len1 = strlen(s1);
len2 = strlen(s2);
for(i = 0; i < len1; i++)
{
c1[f(s1[i])]++;
}
for(i = 0; i < len2; i++)
{
c2[f(s2[i])]++;
}
Find(c1, 1);
Find(c2, 2);
solve();
}
return 0;
}

hdu4930 Fighting the Landlords(模拟 多校6)的更多相关文章

  1. HDU4930 Fighting the Landlords 模拟

    Fighting the Landlords Fighting the Landlords Time Limit: 2000/1000 MS (Java/Others)    Memory Limit ...

  2. HDU-4930 Fighting the Landlords 多校训练赛斗地主

    仅仅须要推断一个回合就能够了,枚举推断能够一次出全然部牌或者大过对面的牌的可能,注意的是4张同样的牌带两张牌的话是能够被炸弹炸的. #include <iostream> #include ...

  3. HDU 4930 Fighting the Landlords(扯淡模拟题)

    Fighting the Landlords 大意: 斗地主... . 分别给出两把手牌,肯定都合法.每张牌大小顺序是Y (i.e. colored Joker) > X (i.e. Black ...

  4. HDU 4930 Fighting the Landlords(暴力枚举+模拟)

    HDU 4930 Fighting the Landlords 题目链接 题意:就是题中那几种牌型.假设先手能一步走完.或者一步让后手无法管上,就赢 思路:先枚举出两个人全部可能的牌型的最大值.然后再 ...

  5. 2014多校第六场 1010 || HDU 4930 Fighting the Landlords (模拟)

    题目链接 题意 : 玩斗地主,出一把,只要你这一把对方要不了或者你出这一把之后手里没牌了就算你赢. 思路 : 一开始看了第一段以为要出很多次,实际上只问了第一次你能不能赢或者能不能把牌出尽. #inc ...

  6. HDU 4930 Fighting the Landlords --多Trick,较复杂模拟

    题意:两个人A和B在打牌,只有题目给出的几种牌能出若A第一次出牌B压不住或者A一次就把牌出完了,那么A赢,输出Yes,否则若A牌没出完而且被B压住了,那么A输,输出No. 解法:知道规则,看清题目,搞 ...

  7. 2014 多校联合训练赛6 Fighting the Landlords

    本场比赛的三个水题之一,题意是两个玩家每人都持有一手牌,问第一个玩家是否有一种出牌方法使得在第一回和对方无牌可出.直接模拟即可,注意一次出完的情况,一开始没主意,wa了一发. #include< ...

  8. HDU 4930 Fighting the Landlords(模拟)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4930 解题报告:斗地主,加了一个四张可以带两张不一样的牌,也可以带一对,判断打出一手牌之后,如果对手没 ...

  9. hdu 4930 Fighting the Landlords--2014 Multi-University Training Contest 6

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4930 Fighting the Landlords Time Limit: 2000/1000 MS ...

随机推荐

  1. 【原创】Linux环境下的图形系统和AMD R600显卡编程(4)——AMD显卡显存管理机制

    显卡使用的内存分为两部分,一部分是显卡自带的显存称为VRAM内存,另外一部分是系统主存称为GTT内存(graphics translation table和后面的GART含义相同,都是指显卡的页表,G ...

  2. VS2013 生成sqlite3动态连接库及sqlite3.dll的调用

    一,生成sqlite3动态连接库1,去sqlite官网上下载最近的sqlite源码包,解压后得到四个文件:shell.c,sqlite3.c,sqlite3.h,sqlite3ext.h此处还需要sq ...

  3. c/c++类型转换相关总结

    在c语言中存在两种类型转换:显式类型转换和隐式类型转换: 显示类型转换:在类型前加上(type)变量,对变量进行的转换,程序员自己显式添加: char *ptra = (char*)ptrb; voi ...

  4. javascript验证前端页面

    数据表结构 1.html页面 <!DOCTYPE html> <html> <head> <title>注册</title> <met ...

  5. WebBrowser(超文本浏览框)控件默认使用IE9,IE10的方法

    C#和易语言都可以使用该方法来变更默认的的IE版本 该文是通过修改注册表的方法实现,测试的时候发现易语言本身也是采用的这种方法 操作方法 打开注册表 HKEY_LOCAL_MACHINE (or HK ...

  6. (1)Java Spring

    Spring 4种关键策略: 基于POJO的轻量级和最小侵入编程 通过依赖注入和面向接口实现松耦合 基于切面和惯例进行声明式编程 通过切面和模板减少样板式代码

  7. (32)C#文件读写

    一.File 类 这是一个静态类,提供用于创建.复制.删除.移动和打开单一文件的静态方法,并协助创建 FileStream 对象 using System.IO; 没有构造函数和属性  写入数据 1. ...

  8. UVA 1395 Slim Span 最小生成树

    题意: 给你一个图,让你求这个图中所有生成树中满足题目条件的,这个条件是生成树中最长边与最短边的差值最小. 思路: 根据最小瓶颈生成树的定义:在一个有权值的无向图中,求一个生成树最大边的权值尽量小.首 ...

  9. 洛谷——P2118 比例简化

    P2118 比例简化 题目描述 在社交媒体上,经常会看到针对某一个观点同意与否的民意调查以及结果.例如,对某一观点表示支持的有1498 人,反对的有 902人,那么赞同与反对的比例可以简单的记为149 ...

  10. POJ2955 Brackets(区间DP)

    给一个括号序列,求有几个括号是匹配的. dp[i][j]表示序列[i,j]的匹配数 dp[i][j]=dp[i+1][j-1]+2(括号i和括号j匹配) dp[i][j]=max(dp[i][k]+d ...