#abc229h. H - Advance or Eat
H - Advance or Eat
Score : points
问题陈述
有一个 行和 列的网格,其中每个格子上有一个白色棋子、一个黑色棋子或什么都没有。
从顶部数第 行、从左边数第 列的格子由 描述。如果 是 W
,则该格子上有白色棋子;如果 是 B
,则有黑色棋子;如果 是 .
, 则为空。
Takahashi 和 Snuke 将进行一场游戏,两位玩家轮流行动,Takahashi 先手。
在 Takahashi 的回合,他执行以下操作之一:
- 选择一个可以向上移动一格到空格的 白色 棋子,并将其向上移动一格(见下文)。
- 吃掉他选择的一个 黑色 棋子。
在 Snuke 的回合,他执行以下操作之一:
- 选择一个可以向上移动一格到空格的 黑色 棋子,并将其向上移动一格。
- 吃掉他选择的一个 白色 棋子。
当玩家无法执行操作时,该玩家输掉游戏。当双方都采取最优策略时,哪位玩家会获胜?
这里,将棋子向上移动一格意味着将位于第 行第 列的棋子移动到第 行第 列。
请注意,这对两名玩家来说是相同的;他们从相同的方向看棋盘。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is a grid with rows and columns, where each square has one white piece, one black piece, or nothing on it.
The square at the -th row from the top and -th column from the left is described by . If is W
, the square has a white piece; if is B
, it has a black piece; if is .
, it is empty.
Takahashi and Snuke will play a game, where the players take alternate turns, with Takahashi going first.
In Takahashi's turn, he does one of the following operations.
- Choose a white piece that can move one square up to an empty square, and move it one square up (see below).
- Eat a black piece of his choice.
In Snuke's turn, he does one of the following operations.
- Choose a black piece that can move one square up to an empty square, and move it one square up.
- Eat a white piece of his choice.
The player who becomes unable to do the operation loses the game. Which player will win when both players play optimally?
Here, moving a piece one square up means moving a piece at the -th row and -th column to the -th row and -th column.
Note that this is the same for both players; they see the board from the same direction.
Constraints
- is an integer.
- is
W
,B
, or.
.
Input
Input is given from Standard Input in the following format:
Output
If Takahashi will win, print Takahashi
; if Snuke will win, print Snuke
.
Sample Input 1
3
BB.
.B.
...
Sample Output 1
Takahashi
If Takahashi eats the black piece at the -st row and -st columns, the board will become:
.B.
.B.
...
Then, Snuke cannot do an operation, making Takahashi win.
Note that it is forbidden to move a piece out of the board or to a square occupied by another piece.
Sample Input 2
2
..
WW
Sample Output 2
Snuke
Sample Input 3
4
WWBW
WWWW
BWB.
BBBB
Sample Output 3
Snuke
update @ 2024/3/10 10:02:23