시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 5 | 3 | 3 | 60.000% |
Volleyball has been an Olympic sport since 1964. Teams of 6 players (in beach volleyball: 2 players) hit a ball back and forth, but each team can only touch the ball up to three times until they need to hit it to the other side. There are additional rules, such as the same player not being allowed to touch the ball twice in a row, etc., which make keeping track of the score quite tedious. This is where you come in and write a program to solve this problem for them.
Here’s a more precise refresher of volleyball rules. The two teams each consist of 6 players: Team A’s players are numbered 1–6 in this problem, and Team B’s players are 7–12. The two teams take turns serving. The other team wins the point when one of the following things happen to your team:3
Given a sequence of who touched the ball, your goal is to find out the current score (notice that “touching” the ball may include serving it). You also should output an error message if at any point in time, the wrong team served.
3We will ignore effects of the net here, as well as a few other details, including the fact that the person serving the ball must normally rotate.
The first line contains a number K ≥ 1, which is the number of input data sets in the file. This is followed by K data sets of the following form:
The first line of a data set contains a number t with 1 ≤ t ≤ 1000. The second line is a sequence of t “ball touches”, separated by one empty space, as follows:
The first “ball touch” is always a number, representing the person who served first. The point may be ongoing at the end of the sequence. The input will never contain impossible sequences (except wrong serves).
For each data set, first output “Data Set x:” on a line by itself, where x is its number. Then, output the score of the two teams, separated by a single white space. If at any point during the sequence, a player from the wrong team served, output “Wrong Serve” instead of the score.
2 21 1 X 9 A 3 7 7 7 3 4 5 B 2 8 11 10 3 4 9 B 12 7 1 X 9 A 8 X 7
Data Set 1: 3 2 Data Set 2: Wrong Serve