UVAOJ131

Written by    18:15 February 24, 2015 

UVAOJ131

131 – The Psychic Poker Player

Time limit: 3.000 seconds

 The Psychic Poker Player 

In 5-card draw poker, a player is dealt a hand of five cards (which may be looked at). The player may then discard between zero and five of his or her cards and have them replaced by the same number of cards from the top of the deck (which is face down). The object is to maximize the value of the final hand. The different values of hands in poker are given at the end of this problem.

Normally the player cannot see the cards in the deck and so must use probability to decide which cards to discard. In this problem, we imagine that the poker player is psychic and knows which cards are on top of the deck. Write a program which advises the player which cards to discard so as to maximize the value of the resulting hand.

Input and Output

Input will consist of a series of lines, each containing the initial five cards in the hand then the first five cards on top of the deck. Each card is represented as a two-character code. The first character is the face-value (A=Ace, 2-9, T=10, J=Jack, Q=Queen, K=King) and the second character is the suit (C=Clubs, D=Diamonds, H=Hearts, S=Spades). Cards will be separated by single spaces. Each input line will be from a single valid deck, that is there will be no duplicate cards in each hand and deck.

Each line of input should produce one line of output, consisting of the initial hand, the top five cards on the deck, and the best value of hand that is possible. Input is terminated by end of file.

Use the sample input and output as a guide. Note that the order of the cards in the player’s hand is irrelevant, but the order of the cards in the deck is important because the discarded cards must be replaced from the top of the deck. Also note that examples of all types of hands appear in the sample output, with the hands shown in decreasing order of value.

Sample Input

Sample Output

总体来说进一步刷新了我心目中模拟题的下限。。。

题目样例输出已经从上往下从强到弱给出了各种组合的名称。

具体是这样的:

这里也可以利用二进制数来进行状态压缩,然后就各种判断属于什么类型,乍看确实头很大,但是首先可以发现花色和点数是分开判断的,两者之间没有交集,花色也只有全部相同和没有全部相同两种情况,然后点数只有递增1、4张相同、3张相同2张相同、3张相同2张不同、只有两对相同和只有一对相同,其实从上往下一个套一个地判断其实还是蛮容易理清楚的,需要注意的是A 2 3 4 5 和 T J Q K A都是合法递增1,特判一下即可。

 

Category : acmstudy

Tags :