#P1443. 马的遍历
马的遍历
Description
There is an chessboard. A knight is at . Compute, for every square on the board, the minimum number of moves the knight needs to reach it.
Input Format
A single line containing four integers .
Output Format
An matrix where each entry is the minimum number of moves for the knight to reach that square (output if it is unreachable).
3 3 1 1
0 3 2
3 -1 1
2 1 4
Hint
Constraints and Conventions
For all test points, it is guaranteed that , .
After August 2022, the requirement on fixed field width in the output was removed. For compatibility, outputs where each integer is separated by spaces or by reasonable field widths will both be judged correct.
Translated by ChatGPT 5
京公网安备 11011102002149号