|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|1 초||128 MB||0||0||0||0.000%|
In the game of poker, each player holds 5 playing cards in their hand. At the end of the final round each player reveals their cards, and the player with the most valuable hand wins the game. Your goal is to write a program that reads in the poker hands of each player, determines their relative worth, and then prints them back out in sorted order from most to least valuable.
Poker is played with a deck of 52 cards, evenly divided into 4 suits: hearts (♥), spades (♠), diamonds (♦), and clubs (♣). Each suit has 13 cards, and each card within the suit has a unique rank that determines the relative worth of the card. From highest to lowest (i.e. from most to least valuable) these ranks are: ace (high), king, queen, jack, 10, 9, 8, 7, 6, 5, 4, 3, 2, ace (low). Although only one ace card exists within each suit, and it is usually ranked as the highest card, under some circuimstances the ace card will be treated as the lowest. The suit itself has no bearing on the worth of the card and is only used to determine which category a particular hand belongs to (in particular the flush and straight flush categories; see below).
Each poker hand can be classified into one of nine categories depending on the combination of cards within that hand. A higher category hand always beats any other lower category hand regardless of the individual card ranks within either hand. If both hands belong to the same category, then the individual card ranks are used to decide which hand is more valuable. Note that each category has slightly different rules about how the individual card ranks break the tie. Also note that the category classification does not depend on the permutation of cards within a hand (i.e. the position of individual cards within a hand does not matter). The possible hand categories are listed below from most to least valuable:
Input to this problem will begin with a line containing a single integer N (1 ≤ N ≤ 100) indicating the number of data sets. Each data set will consist of a line with an integer M (1 ≤ M ≤ 100) specifying the number of poker hands in this data set, followed by a description of the cards in each player's hand with each hand specified on a separate line. Each playing card is described by a two character string, and a poker hand consists of five such strings separated by spaces:
Q”, and “
J” respectively specifying ace, king, queen, and jack.
0” (number zero) specifying a card of rank 10.
2” through “
9” specifying a card of the same numeric rank.
D”, and “
C” respectively specifying hearts, spades, diamonds, and clubs.
You may assume that in the input the same card (i.e. having the same rank and suit) will never appear more than once within a single poker hand.
For each data set in the input, output the heading “
Data Set #k” where k is 1 for the first data set, 2 for the second, etc. Following the heading, output the poker hands (one per line) from the input in sorted order from the most to least valuable. You may assume that no two poker hands in the input have the same relative worth, therefore a unique sorted order will exist for each data set. The individual cards within each hand must be printed in the same order as read in from the input.
1 4 AS 3C 3S JC AH 7C 4C 8C 6C 5C QD 2H 8S 9C QH 0S KS 2S 6S 7S
Data Set #1 7C 4C 8C 6C 5C 0S KS 2S 6S 7S AS 3C 3S JC AH QD 2H 8S 9C QH