QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 256 MB 満点: 100

#11927. 五轮梭哈

統計

梭哈(Show Hand)是一种扑克牌游戏。共有 52 张牌,每张牌都有一个数字和一个花色。共有 13 种不同的数字,分别为 2, 3, 4, 5, 6, 7, 8, 9, T(数字 10), J(数字 11), Q(数字 12), K(数字 13)和 A(数字 1 或 14);共有 4 种不同的花色,分别为方块(d)、梅花(c)、红桃(h)和黑桃(s)。一张牌可以用它的数字和花色来表示。例如,数字 10、花色为方块的牌表示为 “Td”,其中 “T” 代表数字 10,“d” 代表方块花色。一手牌由 5 张牌组成。共有 9 种不同的牌型,按从好到坏的顺序排列如下:

  • “同花顺(Straight Flush)”:5 张数字连续且花色相同的牌。例如:Td Jd Qd Kd Ad。
  • “四条(4 of a Kind)”:4 张数字相同的牌加上任意一张单牌。例如:2d 2c 2h 2s 3d。
  • “葫芦(Full House)”:3 张数字相同的牌加上另外 2 张数字相同的牌。例如:6d 6h 6s 7c 7s。
  • “同花(Flush)”:5 张花色相同但数字不连续的牌。例如:2h 3h Qh Kh Ah。
  • “顺子(Straight)”:5 张数字连续但花色不全相同的牌。例如:As 2s 3s 4d 5d。
  • “三条(3 of a Kind)”:3 张数字相同的牌,其余 2 张牌的数字各不相同。例如:Td Tc Ts 9s As。
  • “两对(2 Pairs)”:2 对数字相同的牌,剩余的一张牌数字不同。例如:3h 3s 6c 6h 4h。
  • “一对(1 Pair)”:2 张数字相同的牌,其余 3 张牌的数字各不相同。例如:4d 4c 2c 5d Ac。
  • “高牌(High Card)”:5 张数字不连续且花色不全相同的牌。例如:2c 3d 8c 9h Ah。

五轮梭哈游戏共有 2 名玩家。游戏开始时,每位玩家从发牌员处获得 25 张牌。随后,在每一轮中,每位玩家从自己持有的牌中选择 5 张组成一手牌,并与对方进行比较。牌型更好的玩家赢得该轮。如果双方牌型相同,则弃掉本轮出过的牌并进入下一轮。一场游戏最多进行 5 轮。如果双方在全部 5 轮中牌型都相同,则游戏以平局结束。

双方均采取最优策略。你的任务是找出获胜者以及他所出的牌型。

输入格式

第一行包含一个整数,表示测试用例的数量(最多 600 个)。 对于每个测试用例,包含两行。第一行是玩家 1 获得的 25 张牌,第二行是玩家 2 获得的 25 张牌。保证所有 50 张牌各不相同。

输出格式

对于每个测试用例,输出一行,包含获胜者以及他所出的牌型。如果游戏以平局结束,输出 “Tie” 以及双方所出的牌型。

样例

输入 1

3
2d 2h 3d 3c 4d 4s 5d 6h 7d 7c 8d 8c 9d 9s
Td Tc Ts Th Jh Js Qd Qh Kc As Ad
2c 2s 3h 3s 4c 4h 5c 5h 5s 6d 6c 6s 7h 7s
8s 8h 9c 9h Jd Jc Qc Qs Kd Ac Ah
2s 3d 3c 3s 3h 4s 4h 5c 5s 6s 6h 7s 7h 8c
8s Td Th Js Jh Qs Qh Kc Kh Ad As
2d 2h 4d 4c 5d 5h 6d 6c 7d 7c 8d 8h 9d 9c
9s 9h Tc Ts Jd Jc Qd Kd Ks Ac Ah
2d 3d 4d 6d 7d 8d 9d Jd Qd Kd Ad 2c 3c 4c
6c 7c 8c 9c Jc Qc Kc Ac 5h 5s Th
2h 3h 4h 6h 7h 8h 9h Jh Qh Kh Ah 2s 3s 4s
6s 7s 8s 9s Js Qs Ks As 5d Td Tc

输出 1

Player 1, Straight Flush
Player 2, Straight Flush, 4 of a Kind,
Flush, Straight, 1 Pair
Tie, Flush, Flush, Flush, Flush, 2 Pairs

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.