Knight | ||||||
| ||||||
Description | ||||||
The knight in the chessboard wonders the least number of moves to go to square t from squares. The knight has a unique L-shaped move: two squares in one direction either horizontally or vertically, and one square in another direction perpendicular to the first. Help him to solve this problem! | ||||||
Input | ||||||
There are multiple test cases. The first line of input is an integer T indicating the number of test cases. Then T test cases follow. For each test case: Line 1. This line contains the chessboard coordinates of position s indicating the square the knight is currently in. Line 2. This line contains the chessboard coordinates of position t indicating the square the knight wants to go to. The coordinate consists of a lowercase letter from a to h and a digit from 1 to 8. | ||||||
Output | ||||||
For each test case: Line 1. Output the least number of moves. | ||||||
Sample Input | ||||||
1 a1 a3 | ||||||
Sample Output | ||||||
2 同1367,只不过是走L形
|
Hust oj 1388 Knight(BFS)
最新推荐文章于 2019-05-19 10:21:13 发布