编程介的小学生 2017-11-18 04:17 采纳率: 20.5%
浏览 927
已结题

Spade 7

Problem Description
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?

Input
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”.

Output
For each test case, output only one line -- the minimum sum of all four players’ penalty points.

Sample Input
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

Sample Output
0

  • 写回答

1条回答 默认 最新

  • qq_23282543 2018-07-24 01:36
    关注

    [20:04:34] Begin ServicePackProgramming operation.
    [20:04:35] INFO: > Executing Operation: Connect
    [20:04:35] FATAL: --- Can't connect to device !! ---
    [20:04:36] FATAL: Error connecting to the device. Please check your COM port settings. Error code: 1
    [20:04:36] INFO: > Executing Operation: Disconnect
    [20:04:36] ERROR: Error disconnecting from the device. Error code: 0
    [20:04:36] Operation ServicePackProgramming returned.
    [20:04:48] Begin Format operation.
    [20:04:49] INFO: > Executing Operation: Connect
    [20:04:51] INFO: setting break signal
    [20:04:51] INFO: --- please restart the device ---
    [20:05:14] ERROR: ---reading ACK signal failed---
    [20:05:14] WARNING: ---seting break signal to false failed---
    [20:05:16] INFO: setting break signal
    [20:05:16] INFO: --- please restart the device ---
    [20:05:27] ERROR: ---reading ACK signal failed---
    [20:05:28] WARNING: ---seting break signal to false failed---
    [20:05:30] INFO: setting break signal
    [20:05:30] INFO: --- please restart the device ---
    [20:05:43] ERROR: ---reading ACK signal failed---
    [20:05:43] WARNING: ---seting break signal to false failed---
    [20:05:45] INFO: setting break signal
    [20:05:45] INFO: --- please restart the device ---
    [20:05:55] ERROR: ---reading ACK signal failed---
    [20:05:55] WARNING: ---seting break signal to false failed---
    [20:05:55] FATAL: --- Can't connect to device !! ---
    [20:06:02] FATAL: Error connecting to the device. Please check your COM port settings. Error code: -3
    [20:06:02] INFO: > Executing Operation: Disconnect
    [20:06:02] Operation Format returned.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误