P8144 [JRKSJ R4] BBWWBB
Description
There are $6$ pieces on a number line. Initially, the $i$-th piece is placed at $a_i$, and $a$ is strictly increasing.
Among them, pieces $1,2,5,6$ are black, and pieces $3,4$ are white.
During the game, any number of pieces of the same color may exist on the same position at the same time.
There are two sides: Black and White. They take turns to operate:
* Choose a piece of your own color and move it one step to the left or to the right.
* If the destination position contains an opponent's piece and contains exactly $1$ such piece, then you may move there and remove that piece at the same time.
* If the destination position contains multiple opponent pieces, then you may not move to that position.
* When a side has no piece that can be moved, that side loses and the game ends.
Both sides aim, under the premise that they do not lose, to make the opponent lose as much as possible. Both sides use optimal strategies.
Given which side moves first and the positions of all pieces, determine whether the game will continue forever.
Input Format
**This problem has multiple test cases.**
The first line contains an integer $T$, the number of test cases.
The following $T$ lines each describe one test case.
Each test case starts with a character $c$, either $\texttt B$ or $\texttt W$. $c=\texttt B$ means Black moves first, and $c=\texttt W$ means White moves first. Then $6$ integers are given, representing $a_{1\dots 6}$.
Output Format
For each test case, output one line containing `Yes` or `No`. `Yes` means the game will continue forever, and `No` otherwise.
Explanation/Hint
### Constraints
For $15\%$ of the testdata, $c=\texttt B$.\
For $100\%$ of the testdata, $T\le10^5$, $|a_i| \le 10^9$, $c\in\{\texttt B,\texttt W\}$. It is guaranteed that $a$ is strictly increasing.
### Sample Explanation
For the $1$-st test case, one possible sequence of positions is as follows:
```cpp
B:
1 4 6 8 9
B B W B B
W:
1 4 5 8 9
B B W B B
B:
1 5 8 9
B B B B
```
For the $2$-nd test case, one possible sequence of positions is as follows:
```cpp
W:
1 3 6 8 9
B W W B B
B:
1 3 6 8 8
B W W B B
W:
1 3 5 8 8
B W W B B
B:
1 3 5 7 8
B W W B B
W:
1 3 4 7 8
B W W B B
B:
1 3 4 7 7
B W W B B
W:
1 3 3 7 7
B W W B B
B:
1 3 3 6 7
B W W B B
W:
1 2 3 6 7
B W W B B
B:
2 3 6 7
B W B B
W:
2 6 7
W B B
```
After that, White controls `W` to move one step to the left each time. No matter how Black operates, the game can continue forever.
Translated by ChatGPT 5