Submit | All submissions | Best solutions | Back to list |
HS11POK - O-Poker |
Marko, Dusan, Nemanja, Stefan and Devedesetpeto are all pupils attending class III-5 of a Serbian gymnazium. Naturally, they enjoy doing anything but listening to their teachers. One day, they saw TV-poker on TV and decided to kill time in school by throwing cards on the table. In a few weeks they become experts at dealing and throwing but still can not decide who is the winner. Help them to solve this task!
The rules of TV poker are as follows: Players use 52 cards, 13 kinds (ranks) (A,K,Q,J,10,9,8,7,6,5,4,3,2) of each of 4 suits (P,K,H,T). Ranks are sorted by strength (ordered as above), while all suits are equal. At the beginning of each deal, every player receives two cards to start with, and then, after bidding, the dealer lays out five more cards from the remaining part of the deck on the table. Every player chooses five cards from the seven he can see (i.e., the two in his hand and the five lying on the table), so that those five cards form the strongest combination. The player who has the strongest of all combinations is the winner of the deal. If two or more players have the same strength combination then we have multiple winners. Combinations are ranked like this:
- Straight flush A Straight Flush consists of 5 cards in numerical sequence, all of the same suit. The higher straight flush wins. AKQJ10 is the highest straight flush. 5432A is the lowest straight flush.
- Poker The higher 4-of-a-kind wins. If two players have the same 4-of-a-kind, then the highest 5th card wins.
- Full A full house consists of a 3-of-a-kind and a pair. The higher 3-of-a-kind wins. If two players have the same 3-of-a-kind, then the highest pair wins.
- Flush A Flush consists of 5 cards of the same suit. The flush with the higher top card wins. If two flushes have the same top card, then the flush with the higher 2nd-to-top card wins, and so on.
- Straight A Straight consists of 5 cards in numerical sequence. The straight with the higher top card wins. AKQJ10 is the highest straight; 5432A is the lowest straight.
- Trilling The higher 3-of-a-kind wins. If two hands have the same 3-of-a-kind, then the 2 kickers (unpaired cards) are used to break the tie.
- Two pairs The hand with the higher top pair wins. If the top pairs are equal, then the bottom pairs are used to break the tie. If those are also equal, then the kicker (unpaired card) is used to break the tie.
- One pair The hand with the higher pair wins. If the pairs are equal, then the kickers are used to break the tie, first by comparing the highest kicker, then the 2nd highest kicker, and finally the lowest kicker.
- High card If a hand does not fit in any other category, it is judged by high cards. Two hands are compared by taking the highest cards and comparing them. If those are equal, then the 2nd highest are compared, and so on.
Input
In first line of standard input contains one integer T - the number of test cases, 1 <= T <= 3000.
Six lines follow for every test case.
In the first five lines there are three strings separated by spaces: first - the name of player with colon, second – the first card and third – the second card dealt to the player. Cards are given as two adjacent characters: first the suit and then the kind, (suits are denoted by P, K, H or T, and kinds by A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3 or 2).
The sixth line contains a description of the five cards on the table (in the same format as the player’s cards). Those five cards are separated with blank spaces.
Multiple tests are separated with empty line.
Output
For every test case do:
In the first line print integer N, the number of winners for the given deal.
In the next N lines print the name of the winning player, directly followed by a colon, a space, and the name of the winning combination (using the names displayed above in red letters). If there are multiple winners, make sure that the winning players listed on output are arranged in the same order as at input.
Example
Input: 3 Devedesetpeto: K4 T3 Marko: K2 TA Nemanja: H5 P4 Stefan: H3 P2 Dusan: K3 T2 HJ P10 H9 K7 H6 Devedesetpeto: KA T7 Dusan: KK T8 Marko: KQ T9 Nemanja: H7 H8 Stefan: K8 P4 HA PA H10 KJ H2 Marko: KQ T9 Nemanja: H7 T3 Stefan: H8 P4 Dusan: TA T8 Devedesetpeto: KA K8 HA PA H10 KJ H2 Output: 1 Marko:High card 1 Nemanja:Flush 2 Dusan:Trilling Devedesetpeto:Trilling
Explanation
- Test 1: No one has any of the first 8 combinations so Marko’s ace wins the deal by "High card".
- Test 2: Nemanja can form a Flush in hearts (H), which is the strongest combination in this deal.
- Test 3: Trilling of Aces (A) with Jack (J) and Ten (10) for Devedesetpeto and Dusan are the strongest in the third deal.
Scoring
By solving this problem you score 10 points.
Added by: | Tata Dule |
Date: | 2011-12-22 |
Time limit: | 0.200s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: CLOJURE ICK NODEJS PERL6 PY_NBC |
Resource: | High School Programming League |