# HDU4930 Fighting the Landlords 模拟

Fighting the Landlords

# Fighting the Landlords

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

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

Source

2014 Multi-University Training Contest 6

Recommend

hujie

```1     ///全出完
2     //cout<<hh1[1]<<‘,‘<<hh1[2]<<‘,‘<<hh1[3]<<‘,‘<<hh1[4]<<endl;
3     if(h1[17]==1 && h1[16]==1 && len1==2)return 1;///王炸
4     if(hh1[4]==1 && len1==6)return 1;///4带2
5     if(hh1[4]==1 && len1==4)return 1;///炸弹
6     else if(hh1[4]==0 && hh1[3]==1 && ( (len1==3) || (len1==4 && hh1[1]==1) || (len1==5 && hh1[2]==1) ))return 1;///3个、3带1、3带2
7     else if(hh1[4]==0 && hh1[3]==0 && hh1[2]==1 && hh1[1]==0 && len1==2)return 1;///一对
8     else if(len1==1)return 1;///一张```

```1     if(MaxCard(h1,hh1,len1,4,0)<MaxCard(h2,hh2,len2,4,0))return 0;///炸弹没它大 或者 自己没炸弹他有炸弹
2     else if(MaxCard(h1,hh1,len1,4,0)>MaxCard(h2,hh2,len2,4,0))return 1;///炸弹比它大 或者 它没炸弹我有炸弹```

```1     if(MaxCard(h1,hh1,len1,3,2)!=-1 && MaxCard(h1,hh1,len1,3,2)>=MaxCard(h2,hh2,len2,3,2))return 1;
2     if(MaxCard(h1,hh1,len1,3,1)!=-1 && MaxCard(h1,hh1,len1,3,1)>=MaxCard(h2,hh2,len2,3,1))return 1;
3     if(MaxCard(h1,hh1,len1,3,0)!=-1 && MaxCard(h1,hh1,len1,3,0)>=MaxCard(h2,hh2,len2,3,0))return 1;
4     if(MaxCard(h1,hh1,len1,2,0)!=-1 && MaxCard(h1,hh1,len1,2,0)>=MaxCard(h2,hh2,len2,2,0))return 1;
5     if(MaxCard(h1,hh1,len1,1,0)!=-1 && MaxCard(h1,hh1,len1,1,0)>=MaxCard(h2,hh2,len2,1,0))return 1;
6     return 0;```

```  1 //#pragma comment(linker, "/STACK:102400000,102400000")
2 #include<cstdio>
3 #include<cmath>
4 #include<iostream>
5 #include<cstring>
6 #include<algorithm>
7 #include<cmath>
8 #include<map>
9 #include<set>
10 #include<stack>
11 #include<queue>
12 using namespace std;
13 #define ll __int64
14 #define usint unsigned int
15 #define mz(array) memset(array, 0, sizeof(array))
16 #define minf(array) memset(array, 0x3f, sizeof(array))
17 #define REP(i,n) for(int i=0;i<(n);i++)
18 #define FOR(i,x,n) for(int i=(x);i<=(n);i++)
19 #define RD(x) scanf("%d",&x)
20 #define RD2(x,y) scanf("%d%d",&x,&y)
21 #define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
22 #define WN(x) printf("%d\n",x);
23 #define RE  freopen("D.in","r",stdin)
24 #define WE  freopen("1.out","w",stdout)
25
26 char s1[20],s2[20];
27 int len1,len2;
28 int v[256];
29 int h1[20],h2[20],hh1[6],hh2[6];
30
31 void attack(const char s[20],const int &len,int h[20],int hh[6])
32 {
33     for(int i=0;i<len;i++)
34         h[v[s[i]]]++;
35 //    for(int i=0;i<20;i++)
36 //        cout<<h[i]<<‘ ‘;
37 //    puts("");
38     for(int i=3;i<18;i++)
39         hh[h[i]]++;
40 }
41
42 int MaxCard(int h[20],int hh[6],int len,int x,int y)
43 {
44     if(x==4 && hh[4]==0)return -1;
45     if(x==3 && hh[3]+hh[4]==0)return -1;
46     if(x==2 && hh[2]+hh[3]+hh[4]==0)return -1;
47     if(len==0)return -1;
48     int ma=0;
49     for(int i=17;i>=3;i--)
50     {
51         //cout<<i<<‘.‘<<h[i]<<‘ ‘;
52         if(h[i]>=x) {ma=i;break;}
53     }
54     //printf("(%d,%d,%d)break!\n",x,y,ma);
55     if(x==4)return ma;///炸弹
56     if(x==3 && y==0)return ma;///三带0
57     if(x==3 && y==2 && (hh[2]+hh[3]+hh[4]>=2))return ma;///三带2
58     if(x==3 && y==1 && len>=4) return ma;///三带1
59     if(x==2)return ma;///一对
60     if(x==1)return ma;///一张
61     return -1;
62 }
63
64 bool gank()
65 {
66     if(len1==0)return 1;
67     mz(h1);mz(hh1);
68     attack(s1,len1,h1,hh1);
69     ///全出完
70     //cout<<hh1[1]<<‘,‘<<hh1[2]<<‘,‘<<hh1[3]<<‘,‘<<hh1[4]<<endl;
71     if(h1[17]==1 && h1[16]==1 && len1==2)return 1;///王炸
72     if(hh1[4]==1 && len1==6)return 1;///4带2
73     if(hh1[4]==1 && len1==4)return 1;///炸弹
74     else if(hh1[4]==0 && hh1[3]==1 && ( (len1==3) || (len1==4 && hh1[1]==1) || (len1==5 && hh1[2]==1) ))return 1;///3个、3带1、3带2
75     else if(hh1[4]==0 && hh1[3]==0 && hh1[2]==1 && hh1[1]==0 && len1==2)return 1;///一对
76     else if(len1==1)return 1;///一张
77
78     ///一下出不完的
79     mz(h2);mz(hh2);
80     attack(s2,len2,h2,hh2);
81     if(h2[17]>=1 && h2[16]>=1) return 0;///被王炸
82     if(h1[17]>=1 && h1[16]>=1) return 1;///王炸
83     if(MaxCard(h1,hh1,len1,4,0)<MaxCard(h2,hh2,len2,4,0))return 0;///炸弹没它大 或者 自己没炸弹他有炸弹
84     else if(MaxCard(h1,hh1,len1,4,0)>MaxCard(h2,hh2,len2,4,0))return 1;///炸弹比它大 或者 它没炸弹我有炸弹
85     ///下面是都没炸弹的
86     //printf("h1:%d,h2:%d\n",MaxCard(h1,hh1,len1,3,2),MaxCard(h2,hh2,len2,3,2));
87     if(MaxCard(h1,hh1,len1,3,2)!=-1 && MaxCard(h1,hh1,len1,3,2)>=MaxCard(h2,hh2,len2,3,2))return 1;
88     if(MaxCard(h1,hh1,len1,3,1)!=-1 && MaxCard(h1,hh1,len1,3,1)>=MaxCard(h2,hh2,len2,3,1))return 1;
89     if(MaxCard(h1,hh1,len1,3,0)!=-1 && MaxCard(h1,hh1,len1,3,0)>=MaxCard(h2,hh2,len2,3,0))return 1;
90     if(MaxCard(h1,hh1,len1,2,0)!=-1 && MaxCard(h1,hh1,len1,2,0)>=MaxCard(h2,hh2,len2,2,0))return 1;
91     if(MaxCard(h1,hh1,len1,1,0)!=-1 && MaxCard(h1,hh1,len1,1,0)>=MaxCard(h2,hh2,len2,1,0))return 1;
92     return 0;
93 }
94
95 int main()
96 {
97     int T,i,j,k;
98     v[‘Y‘]=17;
99     v[‘X‘]=16;
100     v[‘2‘]=15;
101     v[‘A‘]=14;
102     v[‘K‘]=13;
103     v[‘Q‘]=12;
104     v[‘J‘]=11;
105     v[‘T‘]=10;
106     for(i=3;i<=9;i++)
107         v[‘0‘+i]=i;
108     scanf("%d\n",&T);
109     while(T--)
110     {
111         gets(s1);
112         gets(s2);
113         len1=strlen(s1);
114         len2=strlen(s2);
115         //sort(s1,s1+len1,cmp);
116         //sort(s2,s2+len2,cmp);
117 //        puts(s1);
118 //        puts(s2);
119         if(gank())  puts("Yes");
120             else puts("No");
121     }
122     return 0;
123 }```

HDU4930 Fighting the Landlords 模拟

## HDU 4930 Fighting the Landlords 模拟

_(:зゝ∠)_ 4带2居然不是炸弹,, #include <algorithm> #include <cctype> #include <cassert> #include <cstdio> #include <cstring> #include <climits> #include <vector> #include<iostream> using namespace std; #define N 18 #

## 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): 160    Accepted Submission(s): 52 Problem Description Fighting the Landlords is a card game which has been a heat for ye

## HDU 4930 Fighting the Landlords（扯淡模拟题）

Fighting the Landlords 大意: 斗地主....   分别给出两把手牌,肯定都合法.每张牌大小顺序是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. 给你8种组合:1.

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

HDU 4930 Fighting the Landlords 题目链接 题意:就是题中那几种牌型,如果先手能一步走完,或者一步让后手无法管上,就赢 思路:先枚举出两个人所有可能的牌型的最大值,然后再去判断即可 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; struct Player { int rank[15]; } p1, p2; int t, h