#P1013. Checkmate (easy version)
Checkmate (easy version)
题目描述
The only difference between easy version and hard version is that easy version has some simplification.
One day, little m is playing chess. When he is thinking about it, his teacher Mr. M comes who likes playing chess too. When he sees little m is confused by the circumstance on the chess board, he comes out a game with the chess. We all know if our king can't move anywhere in the chessboard, we will lose and this is called checkmate. Now, Mr. M wants to give little m a circumstance on the chess board and let little m to check if it is a checkmate.
For more precisely, now we need to check if the white king is dead. Let's suppose that now it's white king's turn, he needs to consider to move or not, if he can move to one position which his opponent the black will not capture him, he wins, and it is not a checkmate, otherwise it is a checkmate.
Please notice that, the white king can just stay where he is if in black's turn, he will not be captured.
Each chess piece has its own way of moving. In the diagrams, the dots mark the squares where the piece can move if there are no intervening piece(s) of either color.
Here are the rules of the chess.
-
The king moves one square in any direction.
-
The rook can move any number of squares along a rank or file, but cannot leap over other pieces.
In one circumstance we only have a white king and other black rooks. The chess board is an board.
And for simplification, the white king can't capture any other black pieces.
picture: chess board
输入格式
First line of the input contains one integer indicates the number of the circumstances.
For each test case, there is a chess board.
The empty cell is '.', the white king is 'W', the black rook is 'R'.
It is guaranteed that there's exactly one white king.
Please notice that there may have more than two same black pieces in the circumstance which is not legal in the true chess.
输出格式
For each testcase, if it is a checkmate, print YES otherwise print NO.
样例
1
...W....
R.......
........
........
........
.......R
........
R.......
NO
1
...WR...
...R....
........
........
........
........
........
........
YES