| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 15 초 | 2048 MB | 1 | 1 | 1 | 100.000% |
Your task is to checkmate the black king using the white king, a camel, and a wazir.
The camel (represented by an inverted knight symbol) is a chess piece that moves in an elongated knight's move: three squares in one direction (one more than a knight) and one square in the other. The wazir (represented by an inverted rook symbol) always moves to an adjacent square along a rank or file, in other words, makes rook moves of length 1. The king moves as in regular chess: to any adjacent square along a rank, file, or diagonal.
Below are the possible moves of all pieces from the e4 square. Squares reachable in one move are marked by a cross.
The rule of declaring a draw after $50$ moves does not apply.
The first line contains an integer $t$: the number of test cases ($1 \leq t \leq 2 \cdot 10^6$). Then $t$ test cases follow.
Each test case is given on a separate line in the following format: squares of the white king, black king, white camel, and white wazir in algebraic notation, followed by a letter "w" or "b" indicating whether it is White's or Black's turn, respectively. Algebraic notation for chessboard squares consists of two characters: a file number encoded by a letter from "a" to "h", and a rank number encoded by a digit from "1" to "8". Ranks are numbered from bottom to top, and files from left to right, as shown in the pictures.
In each test case:
For each test case, print the evaluation of the position on a separate line. The evaluation of the position should be either the number 0 if the position is drawn, or the character "\#" immediately followed by the minimum number of moves required to guarantee a checkmate.
3 f3 f1 f4 g2 w f3 f1 e1 g2 b a1 c3 e5 h8 b
#1 0 #66
The positions in the example look as follows:
This problem assumes the following standard chess rules and concepts: