#K5071. Knight's Tour Challenge
Knight's Tour Challenge
Knight's Tour Challenge
Consider a standard chessboard of size \(n \times n\). A knight is placed at the initial position \((x, y)\) and is allowed to make at most \(k\) moves. The knight moves in an 'L' shape: two squares in one direction and then one square perpendicular to that.
Your task is to determine whether the knight can visit every square on the board (i.e. all \(n^2\) squares) within \(k\) moves. If it is possible, print possible
; otherwise, print impossible
.
inputFormat
The input is read from standard input and consists of four space-separated integers:
- n: the size of the chessboard (the board is \(n \times n\)).
- k: the maximum number of moves allowed.
- x: the starting x-coordinate (row index, 1-indexed).
- y: the starting y-coordinate (column index, 1-indexed).
outputFormat
The output is a single line printed to standard output. It should be possible
if the knight can visit every square within \(k\) moves, and impossible
otherwise.
5 32 1 1
possible
</p>