#K60717. Exact Knight Moves

    ID: 31149 Type: Default 1000ms 256MiB

Exact Knight Moves

Exact Knight Moves

On an N x N chessboard, a knight moves in an L-shape. In each move, the knight can move either

$$ (\pm2, \pm1) \quad \text{or} \quad (\pm1, \pm2) $$

The board positions are labeled with 1-based indices. Given a starting position \((r_1, c_1)\) and a target position \((r_2, c_2)\), determine whether the knight can reach the target in exactly \(K\) moves. Output YES if it is possible, otherwise output NO.

inputFormat

The input consists of a single line containing six space-separated integers:

$$ N\quad r_1\quad c_1\quad r_2\quad c_2\quad K $$

  • N: the size of the chessboard (i.e., the board is N x N).
  • r1 and c1: the starting row and column of the knight.
  • r2 and c2: the target row and column.
  • K: the exact number of moves the knight must use.

All numbers are separated by spaces.

outputFormat

Print a single line containing either YES if the knight can reach the target position in exactly K moves, or NO otherwise.

## sample
8 1 1 8 8 6
YES