提示: 欢迎访问OurACM平台。
Problem 1557 Tennis Score Board

Accept: 42    Submit: 142
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

Tennis is a popular game all over the world. In this problem, you are to implement a score board for tennis in order to display players' scores and other information (if necessary).

Before we get into this problem, let's look at the rule of tennis briefly:

In each game, if a player wins his first point, the score is called 15 for that player; on winning his second point, the score is called 30 for that player; on winning his third point, the score is called 40 for that player, and the fourth point won by a player is scored game for that player except as below:

If both players have won three points, the score is called deuce; and the next point won by a player is scored advantage for that player. If the same player wins the next point, he wins the game; if the other player wins the next point the score is again called deuce; and so on, until a player wins the two points immediately following the score at deuce, when the game is scored for that player.

So, based on the rule above, a score board is to be implemented like this:

 
+----------+--+
|Player1   |S1|
+----------+--+
|Player2   |S2|
+----------+--+
|Ext Info     |
+-------------+

Player1 and Player2 are names of two players, S1 and S2 are the current score of each player. There may be some kinds of information in Ext Info area, they are deuce, game [Player], adv. [Player] (case sensitive).

While displaying score board, player names occupy 10-character-wide space. Player names are left-aligned with trailing spaces. Player scores occupy 2-character-wide space and they are right-aligned with leading spaces. Ext Info occupies 13-character-wide space, and is left-aligned with trailing spaces.

Input

Input contains several test cases:
T
N
Name of player1
Name of player2
<Rounds>

T is the number of test cases (1 < T < 100).

For each test case: N (0 < N < 20) is the number of rounds in the test case. Player names are non-empty strings which are all less than 8 characters and contain only letters. Player1 will never be same as Player2.

Then N rounds follows. Each round is a string indicating the player who win the round. It's guaranteed that the string is equal to either Player1 or Player2.

Output

For each round, display the score board based on the description of this problem. If a player wins a game, scores of each player is reset to zero.

After each test case, please output a blank line.

Sample Input

2 5 A B A A A A A 9 A B A A A B B B A B B

Sample Output

+----------+--+ |A |15| +----------+--+ |B | 0| +----------+--+ | | +-------------+ +----------+--+ |A |30| +----------+--+ |B | 0| +----------+--+ | | +-------------+ +----------+--+ |A |40| +----------+--+ |B | 0| +----------+--+ | | +-------------+ +----------+--+ |A | 0| +----------+--+ |B | 0| +----------+--+ |game A | +-------------+ +----------+--+ |A |15| +----------+--+ |B | 0| +----------+--+ | | +-------------+ +----------+--+ |A |15| +----------+--+ |B | 0| +----------+--+ | | +-------------+ +----------+--+ |A |30| +----------+--+ |B | 0| +----------+--+ | | +-------------+ +----------+--+ |A |40| +----------+--+ |B | 0| +----------+--+ | | +-------------+ +----------+--+ |A |40| +----------+--+ |B |15| +----------+--+ | | +-------------+ +----------+--+ |A |40| +----------+--+ |B |30| +----------+--+ | | +-------------+ +----------+--+ |A |40| +----------+--+ |B |40| +----------+--+ |deuce | +-------------+ +----------+--+ |A |40| +----------+--+ |B |40| +----------+--+ |adv. A | +-------------+ +----------+--+ |A |40| +----------+--+ |B |40| +----------+--+ |deuce | +-------------+ +----------+--+ |A |40| +----------+--+ |B |40| +----------+--+ |adv. B | +-------------+

Source

FOJ月赛-2007年12月

Submit  Back  Status  Discuss