#P1148. Scoring in the "Gong Zhu" Card Game
Scoring in the "Gong Zhu" Card Game
Scoring in the "Gong Zhu" Card Game
The game "Gong Zhu" is an interesting trick-taking card game. Even if you are not familiar with the playing rules, you can appreciate its charm by understanding its scoring system. In a four‐player game, there are only 16 scoring cards:
- The pig card: S12 (Spade 12).
- All heart cards: H1, H2, …, H13 (where H1 represents the Ace of hearts, H2 represents 2, ..., H13 represents King).
- The sheep card: D11 (Diamond 11).
- The double card: C10 (Club 10).
At the end of the game, each player’s score is computed based on the following rules:
- If a player does not hold any one of these 16 scoring cards, his score is 0.
- If any player holds all 16 scoring cards, then that player scores +1000 and every other player scores 0.
- The card C10 (the double card) is special:
- If a player holds only C10 (and no other scoring card), his score is +50.
- If a player holds C10 along with other scoring cards, then the score obtained from the other scoring cards is doubled.
- If not all heart cards are held by a single player, then the following apply for each player:
- Each heart card is assigned a negative point value according to the order:
H1: -50, H2: -2, H3: -3, H4: -4, H5: -5, H6: -6, H7: -7, H8: -8, H9: -9, H10: -10, H11: -20, H12: -30, H13: -40. - S12 is worth -100 points.
- D11 is worth +100 points.
- Each heart card is assigned a negative point value according to the order:
- If all 13 heart cards (H1 to H13) are held by the same player, then:
- The player holding all heart cards gets a flat +200 points from the hearts.
- If that same player also holds both S12 and D11, an extra bonus of +500 points is added.
Note that the double card (C10) is applied after summing the other scoring cards (unless it is the only card, in which case the score is simply +50).
Input/Output Format:
The input consists of 4 lines. Each line contains the scoring cards held by one player, separated by spaces. A line may be empty indicating the player holds no scoring cards. The output should display the scores of the 4 players in order, separated by a space.
Sample Cases:
Example 1:
Input: S12 H3 H5 H13 D11 H8 H9 C10 H1 H2 H4 H6 H7 H10 H11 H12</p>Output: -148 83 -138 -60
Example 2:
Input: H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 H13 S12 C10 D11</p>Output: 200 -200 100 0
Example 3: If one player holds all 16 scoring cards, then his score is +1000 and the others get 0.
inputFormat
The input consists of exactly 4 lines. Each line represents one player’s hand and contains zero or more cards separated by spaces. Each card is represented by a suit letter (S for spades, H for hearts, D for diamonds, C for clubs) immediately followed by a number (1 to 13). Note that only the following 16 cards are considered for scoring: S12, D11, C10 and the 13 heart cards (H1 to H13).
outputFormat
Output a single line containing 4 integers separated by a space, representing the scores of Player 1 through Player 4, in order.
sample
S12 H3 H5 H13
D11 H8 H9
C10 H1 H2 H4 H6 H7
H10 H11 H12
-148 83 -138 -60