当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4032:Fight the Landlord

题目描述
Fight the Landlord (斗地主) is a card game for three players. In each hand one player, the "landlord", plays alone and the others form a team(may called two peasants). The landlord's aim is to be the first to play out all his cards in valid combinations, and the team wins if any one of them manages to play all their cards before the landlord.

A complete deck consists of 52 standard cards plus 2 jokers, red and black. The cards rank from high to low: R(Red Joker), B(Black joker), 2, A, K, Q, J, T(10), 9, 8, 7, 6, 5, 4, 3. Each rank of standard card has 4 cards.

The landlord plays first, and may play a single card or any legal combination. Each subsequent player in anticlockwise order must either pass (play no card) or beat the previous play by playing a higher combination of the same number of cards and same type. There are just two exceptions to this: a rocket can beat any combination, and a bomb can beat any combination except a higher bomb or rocket - see definitions below.

In this game, there are thirteen types of combination that can be played:

1.  Single card - ranking from 3 (low) up to red joker (high) as explained above.
2.  Pair - two cards of the same rank, from 3 (low) up to 2 (high), for example 3-3, A-A.
3.  Triplet - three cards of the same rank, for example 9-9-9.
4.  Triplet with an attached card - a triplet with a single card added, the single card must be different from the triplet, for example 6-6-6-8. These rank according to the rank of the triplet - so for example 9-9-9-3 beats 8-8-8-A.
5.  Triplet with an attached pair - a triplet with a pair added, the ranking being determined by the rank of the triplet - for example Q-Q-Q-6-6 beats 10-10-10-K-K.
6.  Sequence - at least five cards of consecutive rank, from 3 up to ace - for example 8-9-10-J-Q. 2 and jokers cannot be used.
7.  Sequence of pairs - at least three pairs of consecutive ranks, from 3 up to A. 2 and jokers cannot be used. For example 10-10-J-J-Q-Q-K-K.
8.  Sequence of triplets - at least two triplets of consecutive ranks from 3 up to A. 2 cannot be used. For example 4-4-4-5-5-5.
9.  Sequence of triplets with attached cards - an extra card is added to each triplet. Only the triplets have to be in sequence, for example 7-7-7-8-8-8-3-6. The attached cards must be different from all the triplets and from each other. Although triplets of 2 cannot be included in the triplets sequence, a 2 or a joker or one of each can be attached, but not both jokers.
10.  Sequence of triplets with attached pairs - an extra pair is attached to each triplet. Only the triplets have to be in sequence - for example 8-8-8-9-9-9-4-4-J-J. The pairs must be different in rank from each other and from all the triplets. Although triplets of 2 cannot be included in the triplets sequence, a pair of 2 can be attached. Note that attached single cards and attached pairs cannot be mixed - for example 3-3-3-4-4-4-6-7-7 is not valid.
11.  Bomb - four cards of the same rank. A bomb can beat everything except a rocket or a bomb with higher rank.
12.  Rocket - a pair of jokers. It is the highest combination and beats anything else, including bombs.
13.  Quadplex set - there are two types: a quad (four cards of the same rank) with two single cards of different ranks attached, such as 6-6-6-6-8-9, or a quad with two pairs of different ranks attached, such as J-J-J-J-9-9-Q-Q. 2 and jokers can be attached, but you cannot use both jokers in one quadplex set. Quadplex sets are ranked according to the rank of the quad. Note that a quadplex set can only beat a lower quadplex set of the same type, and cannot beat any other type of combination. Also a quadplex set can be beaten by a bomb made of lower ranked cards.

At the beginning of each round, the landlord has 20 cards and the others each get 17 cards, can the landlord has a strategy to bring out his cards all the way alone until he wins the game and leave no chance for the others to play?
输入解释
The first line of the input is T, which stands for the number of test cases you need to solve.

For each case, three lines are given. The first line contains 20 characters describes 20 cards in landlord’s hand. The following two lines each contains 17 characters describe the two peasants’ cards. It is guaranteed that the given 54 cards make up a complete deck.

输出解释
For each case, you should output “Case k: ” first, where k indicates the case number and counts from one. Then output “Yes” or “No”.

输入样例
6
34567TJQKA2222BRKKKA
45678AAQQJJTT3339
45566778889994TJQ
3456789TJQ2222BRKKK3
456789TJQKAAA3344
5566778899TTJJQQA
3456789TJQKKK4BR2222
456789TJQKA9TTJJQ
AAA3334556677889Q
33445566778899JJJ222
B2AAAKQQTT3456789
RKKKAQQTT3456789J
BR33336666KKKK222245
TTTT7777445JJQQAA
99998888455QQJJAA
AAAKKKQQQJJJTTT98765
BR234555666777888
222333444999TJQKA
输出样例
Case 1: Yes
Case 2: Yes
Case 3: No
Case 4: Yes
Case 5: No
Case 6: Yes

提示
 A lot of test cases, pay attention to the efficiency of your program.
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4032

最后修改于 2020-10-25T23:09:26+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
8000/5000MS(Java/Others) 65768/65768K(Java/Others)