|
|||||||||||||||||
|
SPOJ time: 2012-05-26 13:53:40 |
Game of WarProblem code: HS08WAR
War is a very simple card game for two players that is based on pure luck rather than strategy. Both players have a stack of card, and in each round of the game they try to take some of the opponents cards. The player that loses all his cards loses the game. Each round is played as follows:
If at any point a player is supposed to play a card but his stack is empty - he loses. If both players don't have a card to play - then it is a draw. If a player has no cards at the end of a round - he loses. The following picture contains an example of a War game. The values in the boxes show the supposed output of your program after successive rounds.
Write a program that will simulate a war game for a specified number of rounds. Output the stacks of both players if the game has not finished, or two integers depnding on the outcome (see below for a description). InputThe first line of the input will contain an integer - the number of test cases. Each of the test cases consists of
three lines:
The following two lines descibe the stacks for first and second player. The first number is the number of cards (less than 1000), followed by integer-encoded value of cards (Jack is an 11, Queen a 12, King a 13 and an Ace is 14). OutputFor each test case output two lines:
Example 1Input: 5 1 4 14 6 14 6 4 13 9 14 7 2 4 14 6 14 6 4 13 9 14 7 3 4 14 6 14 6 4 13 9 14 7 4 4 14 6 14 6 4 13 9 14 7 5 4 14 6 14 6 4 13 9 14 7 Output: 5 6 14 6 14 13 3 9 14 7 4 14 6 14 13 4 14 7 9 6 7 13 14 9 6 7 14 14 1 6 8 0 8 0 Example 2Input: 10 1 3 6 3 6 3 6 4 6 1 10 2 3 4 5 6 7 8 9 10 11 10 11 10 9 8 7 6 5 4 3 2 2 10 2 3 4 5 6 7 8 9 10 11 10 11 10 9 8 7 6 5 4 3 2 3 10 2 3 4 5 6 7 8 9 10 11 10 11 10 9 8 7 6 5 4 3 2 4 10 2 3 4 5 6 7 8 9 10 11 10 11 10 9 8 7 6 5 4 3 2 5 10 2 3 4 5 6 7 8 9 10 11 10 11 10 9 8 7 6 5 4 3 2 6 10 2 3 4 5 6 7 8 9 10 11 10 11 10 9 8 7 6 5 4 3 2 7 10 2 3 4 5 6 7 8 9 10 11 10 11 10 9 8 7 6 5 4 3 2 8 10 2 3 4 5 6 7 8 9 10 11 10 11 10 9 8 7 6 5 4 3 2 100 10 2 3 4 5 6 7 8 9 10 11 10 11 10 9 8 7 6 5 4 3 2 Output: 0 0 9 3 4 5 6 7 8 9 10 11 11 10 9 8 7 6 5 4 3 2 11 2 8 4 5 6 7 8 9 10 11 12 9 8 7 6 5 4 3 2 11 2 10 3 7 5 6 7 8 9 10 11 13 8 7 6 5 4 3 2 11 2 10 3 9 4 6 6 7 8 9 10 11 14 7 6 5 4 3 2 11 2 10 3 9 4 8 5 5 7 8 9 10 11 15 6 5 4 3 2 11 2 10 3 9 4 8 5 7 6 6 8 9 10 11 7 6 14 5 4 3 2 11 2 10 3 9 4 8 5 7 6 7 9 10 11 7 6 8 5 13 4 3 2 11 2 10 3 9 4 8 5 7 6 8 10 11 7 6 8 5 9 4 12 3 2 11 2 10 3 9 4 8 5 7 6 20 0 ScoringBy solving this problem you score 10 points.
|
||||||||||||||||
| |||||||||||||||||