{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eIn 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. \u003cbr\u003e\u003cbr\u003eNormally 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. \u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"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\u003dAce, 2-9, T\u003d10, J\u003dJack, Q\u003dQueen, K\u003dKing) and the second character is the suit (C\u003dClubs, D\u003dDiamonds, H\u003dHearts, S\u003dSpades). 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. \u003cbr\u003e\u003cbr\u003eEach 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. \u003cbr\u003e\u003cbr\u003e\u003cbr\u003eUse the sample input and output as a guide. Note that the order of the cards in the player\u0027s 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. \u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cpre\u003eHand: TH JH QC QD QS Deck: QH KH AH 2S 6S Best hand: straight-flush\r\nHand: 2H 2S 3H 3S 3C Deck: 2D 3D 6C 9C TH Best hand: four-of-a-kind\r\nHand: 2H 2S 3H 3S 3C Deck: 2D 9C 3D 6C TH Best hand: full-house\r\nHand: 2H AD 5H AC 7H Deck: AH 6H 9H 4H 3C Best hand: flush\r\nHand: AC 2D 9C 3S KD Deck: 5S 4D KS AS 4C Best hand: straight\r\nHand: KS AH 2H 3C 4H Deck: KC 2C TC 2D AS Best hand: three-of-a-kind\r\nHand: AH 2C 9S AD 3C Deck: QH KS JS JD KD Best hand: two-pairs\r\nHand: 6C 9C 8C 2D 7C Deck: 2H TC 4C 9S AH Best hand: one-pair\r\nHand: 3D 5S 2H QD TD Deck: 6S KH 9H AD QH Best hand: highest-card\r\n\u003c/pre\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003eTH JH QC QD QS QH KH AH 2S 6S\r\n2H 2S 3H 3S 3C 2D 3D 6C 9C TH\r\n2H 2S 3H 3S 3C 2D 9C 3D 6C TH\r\n2H AD 5H AC 7H AH 6H 9H 4H 3C\r\nAC 2D 9C 3S KD 5S 4D KS AS 4C\r\nKS AH 2H 3C 4H KC 2C TC 2D AS\r\nAH 2C 9S AD 3C QH KS JS JD KD\r\n6C 9C 8C 2D 7C 2H TC 4C 9S AH\r\n3D 5S 2H QD TD 6S KH 9H AD QH\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eHand: TH JH QC QD QS Deck: QH KH AH 2S 6S Best hand: straight-flush\r\nHand: 2H 2S 3H 3S 3C Deck: 2D 3D 6C 9C TH Best hand: four-of-a-kind\r\nHand: 2H 2S 3H 3S 3C Deck: 2D 9C 3D 6C TH Best hand: full-house\r\nHand: 2H AD 5H AC 7H Deck: AH 6H 9H 4H 3C Best hand: flush\r\nHand: AC 2D 9C 3S KD Deck: 5S 4D KS AS 4C Best hand: straight\r\nHand: KS AH 2H 3C 4H Deck: KC 2C TC 2D AS Best hand: three-of-a-kind\r\nHand: AH 2C 9S AD 3C Deck: QH KS JS JD KD Best hand: two-pairs\r\nHand: 6C 9C 8C 2D 7C Deck: 2H TC 4C 9S AH Best hand: one-pair\r\nHand: 3D 5S 2H QD TD Deck: 6S KH 9H AD QH Best hand: highest-card\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}