New Game
Time limit2sMemory limit1024 MB
Two players move a chip on a matrix according to cell values; decide whether the first player wins, the second player wins, or the game is a draw.
- Level
Medium6 of 10
- Topics
- Graph, BFS, Topological sort
- Solved
- No attempts yet
Statement
Yasha writes an matrix of numbers on a sheet and places a chip in one of its cells. Players move in turns. If the cell with the chip contains a positive number , the player to move may shift the chip cells to the right or cells down. If the cell contains a negative number , the player may shift the chip cells up or cells to the left. The chip cannot leave the matrix. A player who cannot move loses. Anton moves first.
Both players play optimally.
Input
Input: the first line contains two integers and (), the matrix size. Then follow lines with numbers each. All numbers in the matrix have absolute value at most . The last line contains the initial row and column of the chip, both 1-indexed. The chip starts inside the matrix.
Output
Output one of the following: "Anton" if Anton wins, "Yasha" if Yasha wins, or "draw" if neither player can force a win.