Zenyk, Marichka and Chess
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Today Zenyk and Marichka had a wonderful day in the Carpathians, they visited as many as 4 peaks with a height of 747 meters!
The day was wonderful, but very hard and it was finally time to make camp and rest. What should they do in the camp? That’s right — play some game. Marichka is very tired of Zenyk’s weird games, and therefore this time they decided to play a more classic game. Their choice fell on chess.
Marichka is not very good at chess and, perhaps because of this, really dislikes stalemate. To keep Marichka from being sad, they agreed that if one of the players finds themselves in a stalemate situation, they lose.
Zenyk and Marichka started playing, the game lasted for several hours and was very intense. However, in the end, Zenyk gained a significant advantage. Zenyk has two rooks and a king left, while Marichka has only a king. Zenyk understood the inevitability of his victory, and therefore decided to have some fun. He took a piece of paper and wrote down some sequence of moves on it. Next, he allowed Marichka to move her king to any square that is not under attack. Zenyk moves next. Regardless of Marichka’s choice and all her subsequent moves, Zenyk will make all his moves strictly according to what he wrote on the paper. Note that if Zenyk makes an illegal move, he loses.
Can Zenyk write such a sequence of moves that will guarantee him a victory? Zenyk does not have to use all the moves that were written down if victory comes earlier.
Input
The first line contains a single integer \(t\) – the number of test cases.
Each of the next \(t\) lines contains 3 positions \(king\), \(rook1\), \(rook2\) – the positions of the king and Zenyk’s rooks in standard chess notation.
Output
For each test case, in a single line output Yes if there
exists a set of moves guaranteeing victory, and No
otherwise.
Constraints
\(1 \le t \le 2 \cdot 10^{5}\),
\(king\), \(rook1\), \(rook2\) are correctly specified piece positions in chess notation, in the format [A-H][1-8].
It is guaranteed that no two pieces are on the same position.
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 1 A1 C5 H8 | Yes |
Notes
Stalemate is a situation where a player has no legal moves, in classical chess rules a draw is declared in such a case. In Zenyk and Marichka’s chess, a player who cannot make a move loses.
You can learn more about the rules of chess here.
You can see what the position from the example looks like here.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|