|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|3 초||128 MB||0||0||0||0.000%|
The neighborhood kids have come up with another crazy game. Everybody runs back and forth within bounds, but they can only move in straight lines! The rules of the game are as follows:
John thinks that this game is silly, since he could predict the outcome just by knowing the initial configuration. He wants you to write a program to do just that so he can show the other kids and convince them to play better games.
Below is the representation of the first test case. Note that (0,0) is the bottom-left corner.
The first line of input is the number of test cases that follow. Each test case begins with a line containing integers M, N, and P: the field’s width, its height (both measured in “steps”), and the number of players, respectively (M, N, P < 10). The next P lines contain space-separated values, starting with the name of one kid, followed by the x and y coordinates of their starting position on the field and the direction in which they start (N, S, E, or W). No two kids will start in the same spot. The first of the kids listed is “it” for the game. The last line of the test case (≤ 1000) is the number of rounds to play.
For each case output “Case x:” where x is the case number, on a single line, followed by a space, and the name of the winner for that test case.
2 5 5 3 Sam 1 1 N Sally 2 2 W Bartholomew 3 3 S 20 5 5 4 Sam 0 0 N Ed 4 0 W Rebecca 0 4 E Sally 4 4 S 3
Case 1: Sally Case 2: Ed