hdu 4930 Fighting the Landlords 出一手能打完或者打出来后对手没得接 就赢

Fighting the Landlords

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 176    Accepted Submission(s): 62


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.
 

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.
 

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
 


我之前错在这组案例

1

kkk98

3333

输出No

看清楚题意, 只要出一手能打完或者打出来的对手没得接就算自己赢,输出yes;

我先转换牌成数字

我把 牌的张数 分别存在my[ ] 和 yo [ ] 代表自己的牌和对手的牌.

首先要判断 一手牌打完,  王炸 和炸弹 这几个情况.

mybig [i] 和 yobig[i]  分别代表 第i 种牌型 自己和对手最大的是什么牌. 0 表示没这种牌型.

一次比较,只要有一张牌型比对手大 或者一样大,就是赢了.

#include<stdio.h>
#include<string.h>
int turn (char a)
{
	if(a=='A')
		return 14;
	if(a=='2')
		return 15;
	if(a=='X')
		return 16;
	if(a=='Y')
		return 17;
	if(a=='T')
		return 10;
	if(a=='J')
		return 11;
	if(a=='Q')
		return 12;
	if(a=='K')
		return 13;
	else
		return a-'0';
}
int mybig[11]; 
int yobig[11]; 
int main()
{
	int i,t;
	char s[100];
	int my[100];
	int yo[100];
	int yodan,flag,j,mydan,mysum,yosum;
	scanf("%d",&t);
	while(t--)
	{
		memset(my,0,sizeof(my));
		memset(yo,0,sizeof(yo));
		memset(mybig,0,sizeof(mybig));
		memset(yobig,0,sizeof(yobig));
		scanf("%s",s);
		mysum=yosum=0;
		 
		flag=0;//一手牌打完
		for(i=0;s[i]!=0;i++)
		{
			my[turn(s[i])]++;
			mysum++;
		}
		scanf("%s",s);
		for(i=0;s[i]!=0;i++)
		{
			yo[turn(s[i])]++;  //1 单张 2对子 3 三张    4 三带1// 5  3带一样的2  // 6  4 带任意两个单 //8 王炸, //9 炸弹
			yosum++;
		}

		yodan=mydan=0;
		for(i=0;i<20;i++)//单
		{
			if(my[i])
			{
				mybig[1]=i;
				if(mysum==1)
					flag=1;
			}
			if(yo[i])
				yobig[1]=i;
		}


		for(i=0;i<20;i++)//对子
		{
			if(my[i]>=2)
			{
				mybig[2]=i;
				if(mysum==2)
					flag=1;
			}

			if(yo[i]>=2)
			{
				yobig[2]=i;
			}
		}

		for(i=0;i<20;i++)//3 
		{
			if(my[i]>=3)
			{
				mybig[3]=i;
				if(mysum==3)
					flag=1;
			}
			if(yo[i]>=3)
				yobig[3]=i;
		}


		for(i=0;i<20;i++)//3 1
		{
			if(my[i]>=3&&mysum>=4)
			{
				mybig[4]=i;
				if(mysum==4)
					flag=1;
			}
			if(yo[i]>=3&&yosum>=4)
				yobig[4]=i;
		}

		for(i=0;i<20;i++)// 3 2
		{
			if(my[i]>=3)
			{
				for( j=0;j<20;j++)
				{
					if(my[j]>=2&&j!=i)
						break;
				}
				if(j<20)
				{
					mybig[5]=i;
					if(mysum==5)
						flag=1;
				}
			}

			if(yo[i]>=3)
			{
				for(  j=0;j<20;j++)
				{
					if(yo[j]>=2&&j!=i)
						break;
				}
				if(j<20)
					yobig[5]=i;
			}
		}//  mybig[] 所存的, mybig[1] 是单张最大的牌  1 单张 2对子 3 三张   // 4 三带1// 5  3带一样的2  // 6  4 带任意两个单 //8 王炸, //9 炸弹  

		for(i=0;i<20;i++)//4带2
		{
			if(my[i]>=4&&mysum==6)
			{
				flag=1;
			}
			if(my[i]>=4)
			{
				mybig[9]=i;
				if(mysum==4)
					flag=1;
			}
			if(yo[i]>=4)
			{
				yobig[9]=i;
			}
		}

		if(flag||(my[16]&&my[17]))//王炸或者一手清
		{
			puts("Yes");
			continue;
		}
	    if(yo[16]&&yo[17])
		{
			puts("No");
			continue;
		}

		if(mybig[9]>=yobig[9]&&mybig[9]!=0) //炸弹大他的 而且自己肯定得有炸弹
		{
			puts("Yes");
			continue;
		}
	    
		if(mybig[9]<=yobig[9]&&yobig[9]!=0) //炸弹小他的  而且他肯定得有炸弹
		{
			puts("No");
			continue;
		}


	
		for(i=1;i<=5;i++)
		{
			if(mybig[i]>=yobig[i]&&mybig[i]!=0)// 任意牌型大于 对手
				flag=1;
		}
		if(flag)
		{
			puts("Yes");
			continue;
		}

		
		puts("No");

	}
	return 0;
}







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值