|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||4||1||1||100.000%|
In the card game Wolf (a variant of the famous card games War and Svälta räv), two players both have a set of cards, which together form a normal deck of playing cards. Such a deck contains 52 cards, with each card being a unique combination of one of 4 suits and 13 ranks.
During a turn, each player picks the topmost card from their piles, and shows it. This process is repeated until the two cards have the same suit. Then, the player with the highest rank receives all the cards, which are shuffled into the deck. The turn then ends. The turn also ends if any player, when they are suppoed to pick a card from their pile, has an empty pile. That player will then lose the game. This means that the game can be tied, if the two players both try to pick a new card simultaneously.
Your opponent is currently taking a bathroom break, so you have the opportunity to reshuffle your decks. You cannot exchange any cards, since your opponent knows the set of cards in their deck. Is it possible to reshuffle the deck, so that you win during the next turn?
The first line of input contains the number of cards in your hand (0 ≤ n ≤ 52). Each of the next n lines contains a card specified by a number from 1 to 13 and one of the letters ’C’, ’D’, ’H’, ’S’, separated by a space.
The letter of a card specifies its suit (either clubs, diamonds, hearts or spades, respectively). The number of a card specifies the rank of the card. For simplicity, aces are represented as a 1, and jacks, queens and kings are represented as the numbers 11, 12 and 13. For the purpose of this problem, we consider a rank a to be lower than a rank b if the number of rank a is lower than the number of rank b (meaning aces are of the lowest rank).
Output “Possible” if it is possible to reshuffle the decks, and “Impossible” if it is not.
28 1 C 2 C 3 C 4 C 5 C 6 C 7 C 1 D 2 D 3 D 4 D 5 D 6 D 7 D 1 H 2 H 3 H 4 H 5 H 6 H 7 H 1 S 2 S 3 S 4 S 5 S 6 S 7 S