atcoder#ABC201D. [ABC201D] Game in Momotetsu World
[ABC201D] Game in Momotetsu World
Score : points
Problem Statement
We have a grid with rows and columns of squares, where each square is blue or red. The square at the -th row and -th column is blue if is +
, and red if is -
.
There is a piece on this grid, which is initially placed on the top-left square. Takahashi and Aoki will play a game using this piece.
Each of the two players has points in the beginning. They will alternately do the following operation, with Takahashi going first:
- Move the piece one square right or one square down. It is not allowed to move the piece outside the grid. Then, the player (who moved the piece) gets one point if the piece is now on a blue square, and loses one point if the piece is now on a red square.
The game ends when one of the players is unable to do the operation. Then, the player with the greater number of points wins the game if they have different numbers of points. Otherwise, the game is drawn. Find the result of the game when both players play the game to get the best outcome.
Constraints
- is
+
or-
.
Input
Input is given from Standard Input in the following format:
Output
If Takahashi will win, print Takahashi
; if Aoki will win, print Aoki
; if the game will be drawn, print Draw
.
3 3
---
+-+
+--
Takahashi
Takahashi has a winning strategy described below.
First, Takahashi moves the piece right, which makes him lose one point because the piece goes to a red square. Now, Takahashi has point and Aoki has points. Then,
- if Aoki moves the piece right, Takahashi moves it down;
- if Aoki moves the piece down, Takahashi moves it right.
In either case, Aoki moves the piece to a red square losing one point, and Takahashi moves the piece to a blue square getting one point, which means now Takahashi has points and Aoki has point. The piece is now on the square at the -nd row from the top and -rd column from the left, and Aoki can only choose to move it down, to a red square. Now, Takahashi has points and Aoki has points. The piece cannot move right or down anymore, so the game ends. Since Takahashi has the greater number of points, he wins.
2 4
+++-
-+-+
Aoki
Aoki can win the game, regardless of what choices Takahashi makes.
1 1
-
Draw
In this case, the game immediately ends. Since both players have points, the game is drawn.