問題一覧 > 通常問題

No.88 Whose Turn Is Next?

レベル : / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 602
作問者 : リチウム
お気に入りにしたユーザー ProblemId : 148 / 自分の提出
問題文最終更新日: 2026-06-25 02:14:48
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
yukicoder contest 57 (順位表) の他の問題:

Problem Statement

There is a board game called Reversi (also known as Shirokuro or Othello), played with an 8×8 board and 64 stones that are white on one side and black on the other.
Oda-kun and Yukiko-chan are now playing this Reversi.
However, they got a little tired, so they decided to take a break in the middle of the game.
When they tried to resume the game after the break, they found that they had both forgotten whose turn was next.
They remember only who moved first (playing black), and that neither of them passed even once.
From the current state of the board, tell them which of them should place a stone next.
Note that the player whose turn is next will not pass.

* Reversi is a game in which you flip all of the opponent's stones that are sandwiched, in a straight line of adjacent squares vertically, horizontally or diagonally, between your newly placed stone and a stone of yours already on the board.
  If you cannot place a stone in a way that sandwiches the opponent's stones, you pass and it becomes the opponent's turn.
  Two black stones and two white stones are placed diagonally on the central 4 squares of the board, and black always moves first.
  The game ends when neither player can sandwich the opponent's stones or when all 64 squares are filled. The player with more stones of their color wins.
 Reference: Wikipedia
http://ja.wikipedia.org/wiki/%E3%82%AA%E3%82%BB%E3%83%AD_%28%E9%81%8A%E6%88%AF%29#.E5.9F.BA.E6.9C.AC.E7.9A.84.E3.81.AA.E3.83.AB.E3.83.BC.E3.83.AB

Input

$S$ 
$B_1$
$B_2$
$\vdots$
$B_8$

Line $1$ contains a string $S$ (either "oda" or "yukiko") indicating who moved first.
The next $8$ lines contain strings $B_i$ representing the state of the board.
The $j$-th character of $B_i$ represents the state of the square that is $i$-th from the top and $j$-th from the left. $(1\leq j\leq8)$
The strings consist of three kinds of characters, ".", "b" and "w": "." means the square is empty, "b" means a black stone is placed on it, and "w" means a white stone is placed on it.
It is guaranteed that the answer is uniquely determined.
It is guaranteed that the board is not invalid as a game position.

Output

Output "oda" if the next turn is Oda-kun's, or "yukiko" if it is Yukiko-chan's.
Print a newline at the end.

Sample

Sample 1
Input
oda
........
........
........
...wb...
...bw...
........
........
........
Output
oda

This is the standard initial arrangement. Note that black moves first.

Sample 2
Input
yukiko
........
........
........
..bbb...
...bw...
........
........
........
Output
oda

This arrangement cannot occur in any state other than the one where one stone has been placed from the initial arrangement.

Sample 3
Input
yukiko
........
....w...
..wwww..
..wbww..
..bbbwb.
.b.bb.w.
........
........
Output
yukiko

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。