Knights
Time limit1sMemory limit128 MB
Decide if the first player wins a combinatorial game where all knights with restricted moves must move simultaneously each turn until none can move.
- Level
Hard8 of 10
- Topics
- Game theory, Graph, Math
- Solved
- No attempts yet
Problem
Alice and Bob play a game on an chessboard. Initially black knights are placed on it. No two knights start on the same square, and every knight has at least one legal move at the start.
The players alternate turns and Alice moves first. On each turn the current player must move every knight that still has at least one legal move; a knight with no legal move stays on its square. From square a knight may move to any of these four squares, as long as the destination stays on the board (both coordinates between and ):

Several knights may occupy the same square. The first player who cannot move any knight (every knight is stuck) loses. Assume both players play optimally.
Determine whether Alice, who moves first, can win.
Input
The first line contains two integers and (, ).
Each of the next lines contains two integers and () — the square of the -th knight. No two knights share a square, and every knight has at least one legal move.
Output
Print a single line containing YES if Alice can force a win, or NO otherwise.