#P1148. 拱猪计分
拱猪计分
Description
“Gongzhu” is a very interesting card game. Even if you do not know how to play it, you can appreciate its fun from the scoring rules. Here we only consider a four-player Gongzhu deal. Based on the rules below, compute the final score of each player when the deal ends.
- We use to represent Spades, Hearts, Diamonds, and Clubs, and numbers to to represent ranks . For example, is Heart , and is Spade .
- At the end of the deal, the only cards that matter for scoring (scoring cards) are the “Pig” , all Heart cards, the “Sheep” , and the “Double” — a total of cards. All other cards are discarded and do not count (that is, they are not considered in the scoring process below). If a player holds none of these cards, their score is .
- If the player who holds has that card and no other scoring cards, they score points. Otherwise, double the sum of that player’s other scoring cards.
- If the Heart cards are not all held by a single player, then the Heart cards to are negative, with values $-50, -2, -3, -4, -5, -6, -7, -8, -9, -10, -20, -30, -40$ in order. Also, and are scored as and points, respectively.
- If the Heart cards to are all held by a single player, then:
- All Heart cards are scored as points. This means the set of all Heart cards is worth in total, not per card.
- If and are both also held by the same player who took all the Hearts, that player scores points. This does not stack with the from the Hearts. Otherwise, these two cards are scored according to the earlier rules.
- The card is still scored according to the earlier rules.
Example 1: If the players’ scoring cards are:
S12 H3 H5 H13D11 H8 H9C10 H1 H2 H4 H6 H7H10 H11 H12
Then the scores for the four players, in order, are: , and .
Example 2: If the players’ scoring cards are:
H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 H13S12 C10D11- None
Then the scores for the four players, in order, are: , and .
Input Format
Each input file contains multiple test cases.
Each test case has four lines, one per player.
On each line, the first number is the total count of scoring cards held by that player, followed by that many strings describing all their scoring cards. The count and the cards are separated by one or more spaces.
There are no blank lines between consecutive test cases. If all four players’ counts are , the input ends and this test case should not be processed.
Output Format
Each line corresponds to one test case’s result and contains the four players’ scores, in order, as integers with a sign if nonzero. Adjacent integers are separated by a single space.
There is no space between the sign and the number. Do not print blank lines between test cases.
4 S12 H3 H5 H13
3 D11 H8 H9
6 C10 H1 H2 H4 H6 H7
3 H10 H11 H12
13 H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 H13
2 S12 C10
1 D11
0
0
0
0
0
-148 +83 -138 -60
+200 -200 +100 0
Hint
The two sample test cases correspond to the examples in the statement.
Translated by ChatGPT 5
京公网安备 11011102002149号