Road Construction
Time limit2sMemory limit1024 MB
Two players alternately build rectangles of area at most s on an n by m grid, and the task asks whether the first player wins.
- Level
Medium6 of 10
- Topics
- Math, Game theory
- Solved
- No attempts yet
Problem
Sam is not the only person who builds roads. Today he met another builder who does the same job. The two quickly found common ground and decided to play a game.
They are building a rectangular section of road of size meters. Treat it as a grid of cells. Before the game starts, no cell is built.
The players take turns. On a turn, a player picks any rectangle on the grid with area at most in which no cell is built yet, and builds every cell inside it. The player who cannot move loses. Sam moves first.
Determine whether Sam wins when both players play optimally.
Input
The first line contains three integers , , and (, ), the grid size and the maximum area of a rectangle built in one turn.
Output
If Sam can win, print YES on a single line. Otherwise, print NO.