11706 - 231001_12/9_Assignment1
|
Time |
Memory |
| Case 1 |
1 sec |
32 MB |
| Case 2 |
1 sec |
32 MB |
| Case 3 |
1 sec |
32 MB |
| Case 4 |
1 sec |
32 MB |
| Case 5 |
1 sec |
32 MB |
| Case 6 |
1 sec |
32 MB |
| Case 7 |
1 sec |
32 MB |
| Case 8 |
1 sec |
32 MB |
| Case 9 |
1 sec |
32 MB |
| Case 10 |
1 sec |
32 MB |
Description
Texas Hold ‘em
A playing card deck contains 52 cards. Each card has one suit (either clubs, diamonds, hearts or spades) and one card number (Pip cards: 1~10 in which ‘1’ is called “ace”. Face cards: Jack, Queen, and King). This assignment is based on a common card game in the world called “Texas Hold’em (德州撲克)”. There are five “community cards” on the table (which is open to everybody) and own two “hole cards” for each player (private to this player alone). Each player seeks the best five-card poker hand from any combination of the seven cards of the five community cards and their own two hole cards. Only cards’ numerical ranks matter; suit values are irrelevant in this game.
Hands are ranked by their patterns as follows (from the largest to the smallest).
-
Straight Flush (同花順). Five cards of the same suit with consecutive values, ranked by the highest card in the hand. Note that “A K Q J 10” is considered the largest straight and “5 4 3 2 A” is considered the smallest. In Texas Hold ‘em, Ace has 14 points, but Ace is represented as 1 point in “5 4 3 2 A”. That is, “5 4 3 2 A” < “6 5 4 3 2” < “7 6 5 4 3” < … < “K Q J 10 9” < “A K Q J 10”.
-
Quads (鐵支). Four cards with the same number.
-
Full House (葫蘆). Three cards of the same value, with the remaining two cards forming a pair.
-
Flush (同花). Hand contains five cards of the same suit.
-
Straight (順子). This type of hand contains five cards with consecutive values, but five cards are not the same suit.
-
Trips (三條). Three of the cards in the hand have the same value and the remaining two cards do not have the same value.
-
Two Pairs (兩對). This type of hand contains two different pairs.
-
Pair (對子). Two of the five cards in the hand have the same value and the last three cards do not have the same value.
-
High Card (胡亂). Hands which do not fit any category.
Write a program that determines the best pattern of a card hand for each player and find the winner(s). In your input, there are n players (2 ≤ n ≤ 10), the 5 community cards, and n players’ own 2 hole cards. There is only one card deck in each Texas Hold ‘em game. That is, each card appears only one time in each Texas Hold ‘em game. The suits are represented by the characters S, H, D, C (for spade, heart, diamond, and club). The values are represented by 2~9, T (representing 10), J, Q, K, and A. Your program should output the sorted pattern according to the following rules. Suits are ranked as Spade > Heart > Diamond > Club.
Input
Input:
-
The number of players
-
5 Community cards
-
2 hole cards of Player 1
-
2 hole cards of Player 2
-
……
-
2 hole cards of Player n
Input format:
There is a space between two cards, but there is no any space between the suit and the number. Please see the sample input
Output
Output:
-
The best pattern of Player 1
-
The best pattern of Player 2
-
……
-
The best pattern of Player n
-
Who win(s) this game
Output format:
Print the number of the player and the best pattern of each player. After that, you need to decide who win(s) the game. Please see the sample output.
Tags