-->
当前位置:首页 > 题库

PROGRAMMING:White Knight's movement

Luz5年前 (2021-05-10)题库410
Small s first contact with chess. He found that the movement of knight in chess is similar to that of horse in Chinese chess. The movement is shown in the figure.
![ QQ picture 20191115182554. PNG] (~ / ecf163df-0b79-431e-b1fd-db8a11e1ff2f. PNG)
So Xiao s put some pieces on the chessboard, including a white knight, a black queen, some black chariots and some black bishops.
Small s want to know, how to avoid the black chariot and black Bishop's attack range under the premise, spend less steps to eat the black queen.
Note 1: the attack range of chariot is linear, similar to that of Chinese chess chariot; The Bishop's attack range is diagonal and can be extended without obstacles.
Note 2: white knight can only eat black queen, not black chariot and black bishop.
###Input format:
The input contains only one set of samples.
A group of examples contains 8 lines (corresponding to 1-8 lines respectively), each line contains 8 characters, and each character represents the chessboard grid status of the corresponding column of the corresponding line.
Where '.' means there are no chess pieces on the grid; ' K 'stands for white knights on the grid;' Q 'stands for the black queen on the grid R 'stands for black chariots on the grid B 'stands for the black bishop on the grid.
Note: the title guarantees that the initial position of the white knight is not within the attack range of the black chariot and the black bishop.
###Output format:
If the white knight can eat the black queen while avoiding the attack of the black chariot and the black bishop, the minimum number of steps will be output; Otherwise, output "checkmate".
###Input sample 1:
```in
R.B.QB.R
........
........
........
........
........
........
.K......
```
###Output sample 1:
```out
four
```
###Input sample 2:
```in
....RR.Q
........
.K......
........
........
........
........
........
```
###Output sample 2:
```out
Checkmate
```






answer:If there is no answer, please comment