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

建议使用的浏览器:

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

4448:Spade 7

题目描述
Spade 7, or “Bie Qi” in Chinese, is a popular card game using a standard deck of fifty-two cards - The deck consists of four suits of thirteen cards each, coded and sequenced as A (regarded as 1), 2, 3, 4, 5, 6, 7, 8, 9, 10, J (regarded as 11), Q (regarded as 12), and K (regarded as 13). The four suits are club (C), heart (H), spade (S), and diamond (D).
Spade 7 is so easy and funny that can be well suited for any ages, No matter a primary school student or a card game expert, even professional bridge masters are addicted to the spade7. And it allows three to seven players playing together.
These are the rules of Spade 7 in a four-player game:
1.Each player receives thirteen cards.
2.The owner of Spade 7 begins by discarding it. Then the players take turns in anti-clockwise order.
3.In each turn, the player needs to discard one valid card, or fold one card when and only when he does not have any valid cards. A valid card is either a 7 of any suits, or touching another card (with the same suit and the difference between their codes is exactly one) which has been discarded by any player in previous turns.
4.The game ends when nobody has cards in his hands.
Every time someone folds a card, he receives penalty points equals to the code of this card. The goal for each player is, to minimize his penalty points.
As pacifists, Alice and three of her best friends are tired of fighting with each other. So they want to try their best to minimize the sum of all four players’ penalty points. Can you help her figure out the best result?
输入解释
The input begins with a line containing an integer T (1 ≤ T ≤ 20), the number of test cases.
Each test case contains four lines, describing the cards owned by four players at the beginning, one player per line. The four players are given in anti-clockwise order.
Each line contains thirteen strings, separated by spaces. Each string describes one card in the follow format:
1.The string is represented as “suit” + “code”.
2.The “suit” is a character C (for club) or H (for heart) or S (for spade) or D (for diamond).
3.The “code” can be A (regarded as 1), 2, 3, 4, 5, 6, 7, 8, 9, 10, J (regarded as 11), Q (regarded as 12), or K (regarded as 13).
4.NO SPACE between the “suit” and the “code”.
输出解释
For each test case, output only one line -- the minimum sum of all four players’ penalty points.
输入样例
1
HA H2 H3 H4 H5 H6 H7 H8 H9 H10 HJ HQ HK
CA C2 C3 C4 C5 C6 C7 C8 C9 C10 CJ CQ CK
SA S2 S3 S4 S5 S6 S7 S8 S9 S10 SJ SQ SK
DA D2 D3 D4 D5 D6 D7 D8 D9 D10 DJ DQ DK
输出样例
0
来自杭电HDUOJ的附加信息
Recommend zhuyuanchen520

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

源链接: HDU-4448

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

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)