問題一覧 > 通常問題

No.486 3 Straight Win

レベル : / AI推定難易度 : 118 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 665
作問者 : butsurizuki / テスター : tatuyan_edson
お気に入りにしたユーザー ProblemId : 1402 / 自分の提出
問題文最終更新日: 2026-06-25 21:15:47
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. Back to the original
yukicoder contest 157 (順位表) の他の問題:

Problem Statement

The East Army and the West Army are competing in a certain game. In this game, exactly one of the East Army and the West Army always wins and the other always loses.
The two armies agreed to repeat the game several times and that the first side to win 3 games in a row would be the final winner.
However, the two armies got so heated in the competition that they finished playing without knowing who the final winner was.
(Therefore, the armies may have continued playing even after the final winner was determined.)
So the two armies have asked you, the only one who recorded the results, to determine the final outcome.
The record is represented by a single-line string $S$, where 'O' (half-width uppercase letter O) represents a win for the East Army and 'X' (half-width uppercase letter X) represents a loss for the East Army.
For example, "OXOOXXX" means that, starting from the first game, the East Army won, lost, won, won, lost, lost, and lost, so the final winner is the West Army.
Given such an input, print "East" if the East Army wins, "West" if the West Army wins, and "NA" if the final winner is not determined.

Input

$S$

The input consists of only the string $S$, given on a single line. The string $S$ consists only of 'O' and 'X'.
・Constraints
$1\le |S| \le 100$ (where $|S|$ is the length of the string $S$)

Output

As stated above, print "East" if the final winner is determined to be the East Army, "West" if it is determined to be the West Army, and "NA" if the winner is not determined.
A newline is required at the end of the output.

Sample

Sample 1
Input
OXOOXXX
Output
West

This is the example from the problem statement.

Sample 2
Input
OOOXXXX
Output
East

Even though the West Army won 4 games in a row after the East Army won 3 in a row, the final winner is the East Army.
In this case, the games continued even though the final winner had already been determined to be the East Army.

Sample 3
Input
OXOXOXOXOXOX
Output
NA

In this case, neither army ever won 3 games in a row, so print "NA".

Sample 4
Input
O
Output
NA

As in this case, the input may contain fewer than 3 games in the first place.

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