Home Page | Web Board | Problems | Standing | Status | Award Contest |
Problem J:A Card Trick Time Limit:1000MS Memory Limit:65536K Description
The following card trick is performed by a Magician and her Assistant. The Assistant asks a member of the audience to choose 5 cards from a standard deck of 52 cards (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K of C[lubs], D[iamonds], H[earts] and S[pades]). The Assistant returns one of the cards to the audience member and then hands the remaining cards to the Magician, one at a time. After suitable mumbo-jumbo, the Magician identifies the (fifth) card held by the audience member.
Input The first line of the input consists of a positive integer n, which is the number of datasets that follow. Each of the n following lines contain one data set. The dataset is a sequence of 5 cards separated by a space. Each card is given by a one or two character value and a one character suit as described in the first paragraph. Output For each dataset, the output on separate lines is an ordering of the 5 input cards as shown in the sample output. The first card in the sequence is the card to be returned to the audience member. The remaining cards are those given to the Magician (in the order given to the Magician). There may be more than one solution to some problems (but that is not to say there *will* be). In cases such as these, output the smallest one, determine the order base at the order of cards given above. For the first sample below, 10D 4D QH 10C 5H is also a solution but 5H QH 10D 10C 4D < 10D 4D QH 10C 5H. Sample Input
Sample Output
|
[Submit] [Go Back] [Status] [Clarify]
All Copyright Reserved 2003
Any problem, Please Contact Administrator