1D Stone Game 2
Time limit1sMemory limit1024 MB
Two players take turns removing consecutive stones from a 1 by n row, with the move size capped by the previous move, and the task is to find the winner for each n.
- Level
Hard8 of 10
- Topics
- Game theory, Math, Implementation
- Solved
- No attempts yet
Problem
This problem differs from 1D Stone Game 1 only in the bold part.
Dongwoo and Jaewoo play a game on a straight grid. At the start, each cell holds exactly one stone.
The game starts with Dongwoo, and the players take turns. Dongwoo plays on odd-numbered turns, and Jaewoo plays on even-numbered turns.
- On the first turn, choose 1 cell and take the stone on it.
- From the second turn on, if the opponent took stones on the previous turn, choose an integer with , then choose consecutive cells that have stones, and take all stones in those cells.
- After each move, if the remaining stones form two parts separated by the cells that were taken, discard all stones in the part with fewer stones. If both parts have the same number of stones, choose one part and discard its stones. If the remaining stones form only one part, discard nothing.
- A player who cannot make a legal move on their turn loses, and the opponent wins.
Assuming both players play optimally, print who wins.
Input
The first line contains the number of test cases .
Each of the following lines contains the initial number of stones for one test case.
The same does not appear more than once.
Output
For each test case, print kidw0124 if Dongwoo wins, or eoaud0108 if Jaewoo wins. Print one result per line.