#P5013. Bull Fight Scoring Challenge
Bull Fight Scoring Challenge
Bull Fight Scoring Challenge
There are N players and T rounds of a modified Bull Fight (斗牛) card game. In each round exactly three players participate. Every player starts with 0 points. In every round, each participant receives 5 cards. Each card has a rank and a suit. The rank is one of 2, 3, 4, 5, 6, 7, 8, 9, 10 or A (representing 1), and the suit is one of 'a', 'b', 'c', 'd' (with ordering: a > b > c > d, which means spades > hearts > clubs > diamonds).
The rules for evaluating a 5‐card hand are modified as follows:
1. Basic Rules
At the start of each round, every player gets 5 cards. A hand is analyzed according to specific rules. In each hand, aside from special cases (Bomb and No Cow), the five cards are partitioned into two parts: a three‐card group called "Cow" and a two‐card remainder. The score of the hand is the sum of the two remaining cards modulo 10.
2. Hand Types
- Bomb: If among the 5 cards there exist at least 4 cards with the same rank. (When two players have bombs, the bomb with the higher rank wins.)
- Valid Bull Hands: If there is a way to choose 3 cards that either:
(a) are all of the same rank (called Iron Plate), or
(b) have a sum that is a multiple of 10, - Then the remaining 2 cards provide a score = (sum modulo 10). If this score is 0, the hand is called Niu Niu; otherwise it is called Cow X (for example, if the remainder is 5, it is called "Cow Five").
- No Cow: If no such 3-card combination exists.
3. Ranking of Hand Types
The hand types are ranked as follows:
Bomb > Niu Niu > Cow Nine > Cow Eight > … > Cow One > No Cow
When both players have a Bomb, the bomb with the higher card rank wins. For non-Bomb hands with the same bull value, if only one hand used an "Iron Plate" (i.e. 3 cards all of the same rank), that hand wins. If both (or neither) are Iron Plate, then the highest card (evaluated by rank, and if tied, by suit in order a > b > c > d) is used as the tie-breaker.
4. Scoring
In every round, the base score is 10 points. The game is scored by comparing every pair among the three players in the round:
- For each pair of players, after comparing their hands, the winner’s hand type determines the multiplier applied to the base score. The multiplier is determined as follows:
- Bomb: base × 10
- Niu Niu: base × 3
- Cow Seven, Eight, or Nine: base × 2
- Cow One to Six or No Cow: base × 1
- Additionally, if the winning hand (that is not a Bomb) is an Iron Plate (i.e. its valid 3-card group is made of identical cards), the points are doubled after applying the above multiplier.
- The winner gains the computed points and the loser loses the same amount.
Your task is to simulate the entire game. At the end of T rounds, output the final score for each of the N players (players not participating in a round do not change score).
inputFormat
The first line contains two integers N and T, where N is the total number of players and T is the number of rounds played.
For each round, there are exactly 3 lines. Each line begins with an integer (the player ID, 1-indexed) followed by 5 strings representing the cards. Each card is formatted as a concatenation of its rank and suit (for example, "10a" represents rank 10 of suit a, and "Aa" represents Ace of suit a which counts as 1).
outputFormat
Output N lines. The i-th line (1-indexed) should contain the final score of player i after all rounds.
sample
3 1
1 Aa 2b 3c 4d 5a
2 10a 10b 10c 10d Ab
3 9a 9b 9c 2a 3d
-120
200
-80
</p>