Polygon Game
Time limit2sMemory limit512 MB
Two players alternately draw chords inside a convex N-gon that avoid all earlier chords, including shared endpoints; decide the winner under optimal play.
- Level
Hard8 of 10
- Topics
- Game theory, Combinatorics, Dynamic programming, Geometry
- Solved
- No attempts yet
Problem
A convex polygon has vertices. Every interior angle is smaller than , and the vertices are numbered through in clockwise order.
Seonggwan and Hongjun play a game on this polygon. Seonggwan moves first, and the two players alternate turns.
On a turn the player picks two vertices and draws the segment that joins them. The segment is allowed to lie on a side of the polygon. The new segment must not meet any segment drawn earlier. Two segments that touch at an endpoint count as meeting.
The player who cannot draw a segment loses. Given , write a program that decides who wins when both players play optimally.
Input
The first line contains ().
Output
Print if Seonggwan wins, or if Hongjun wins.