#P12111. [NWRRC2024] Game of Annihilation
[NWRRC2024] Game of Annihilation
题目描述
Two players are playing a game on a tape divided into cells that is infinite to the right. The cells are numbered with from left to right. Each cell is adjacent to cells and , except for cell , which is only adjacent to cell .
There is a finite number of red chips (the first player's chips) and blue chips (the second player's chips) on the tape. Each cell contains either several red chips, or several blue chips, or no chips at all.
The players take turns. On their turn, a player can either skip the turn or take one of their chips and move it to an adjacent cell. If there are no opponent's chips in the adjacent cell, the turn ends; if there is at least one opponent's chip there, one chip from each player is removed from that cell --- thus, at the end of the turn, there will still be no two chips of different colors in the same cell.

If both players run out of chips, the game ends in a draw. If only one player runs out of chips, they are declared the loser, and their opponent is declared the winner. Finally, if after turns the game has not ended, it is forcibly concluded and declared a draw.
You are given the initial setup of the tape. Determine who will win with perfect play from both players, and find any optimal first move for the first player.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer , denoting the number of cells that initially contain at least one chip ().
The -th of the following lines contains two integers , , and a character , denoting the coordinate of the -th non-empty cell from the left, the number of chips in it, and the color of these chips (; ; ). There is at least one chip of each color on the tape.
It is guaranteed that the sum of over all test cases does not exceed .
输出格式
For each test case, print:
- , if the first player (moving red chips) will win;
- , if the second player (moving blue chips) will win;
- , if the outcome of the game will be a draw.
In the first and third cases, specifies any winning or drawing move, respectively --- that is, a move after which, with perfect play from the second player, there remains a possibility to win or draw the game. Here, is the coordinate of the red chip that the first player should move, and is the direction of the move ( means the chip should be moved to cell , and means the chip should be moved to cell ). If is , then must be greater than . If you suggest that the first player skips their turn, print instead of .
You can print each letter in upper- or lowercase: for instance, the strings , , will be considered equivalent by the checker.
10
2
1 1 R
2 1 B
2
1 1 B
2 1 R
2
1 2 B
4 1 R
4
1 1 B
2 1 R
4 3 B
6 1 R
2
1 2 B
3 1 R
2
1 2 B
2 1 R
2
1 1 R
2 2 B
2
1 2 R
3 1 B
3
1 1 R
2 1 R
4 1 B
2
1 2 R
2 1 B
Draw 0 0
Draw 2 -
Draw 4 -
Draw 2 -
Draw 0 0
Draw 2 +
Second
Draw 0 0
Draw 2 -
First 1 +
提示
In the last test case, there is only one possible move besides , namely, (skip the turn). It is a drawing move, though; hence, it will not be accepted.