QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#18379. Straight

Statistics

斗地主是中国最流行的扑克牌游戏之一。游戏使用一副标准的 54 张牌(52 张普通牌 + 2 张王牌)。

在斗地主中,顺子是指由至少 5 张点数连续的牌组成的牌型。点数按升序排列依次为:3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A。需要注意的是,2 和王牌不能出现在顺子中。

tarjen 当前手上有 17 张牌,他非常喜欢顺子。他想知道自己能打出的最长顺子的长度。你能帮帮他吗?

如果无法打出任何顺子,则输出 0。

输入格式

第一行包含一个整数 $t$ ($1 \le t \le 1000$) —— 测试用例的数量。

接下来的 $t$ 行,每行包含 17 个空格分隔的字符串,表示 17 张牌。每张牌的表示方法如下:

  • 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A:对应点数的牌
  • 2:点数为 2 的牌
  • SJ:小王
  • BJ:大王

每个测试用例中,每种普通牌(A, 2~10, J, Q, K)最多出现 4 次。小王和大王最多各出现 1 次。

输出格式

对于每个测试用例,输出一个整数 —— 可以打出的最长顺子的长度。如果不存在顺子(即不存在长度 $\ge 5$ 的连续点数序列),则输出 0。

样例

输入样例 1

2
3 4 5 6 7 3 4 5 6 7 2 2 2 2 SJ BJ A
2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 7

输出样例 1

5
0

说明

对于第一个测试用例,可用于组成顺子的点数有 3, 4, 5, 6, 7 和 A。最长的连续序列是 3, 4, 5, 6, 7,长度为 5。

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.