問題一覧 > 通常問題

No.349 Zodiac Figurines

レベル : / AI推定難易度 : 425 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 462
作問者 : nmnmnmnmnmnmnm
お気に入りにしたユーザー ProblemId : 924 / 自分の提出
問題文最終更新日: 2026-06-25 11:43:27
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 133 (順位表) の他の問題:

Problem Statement

There are 12 types of zodiac figurines.
The 12 types are "ne", "ushi", "tora", "u", "tatsu", "mi", "uma", "hitsuji", "saru", "tori", "inu", and "i".
You have $N$ zodiac figurines, where some types may be missing and some types may be duplicated.
You want to arrange the $N$ figurines in a horizontal row, but there is one condition.

- Figurines of the same zodiac type must not be placed next to each other.

Is it possible to arrange them so that this condition is satisfied?

Input

$N$
$A_0$
$A_1$
$\vdots$
$A_{N-1}$

N is a positive integer. $2\le N \le 50$
$A_i$ is a string representing the type of the i-th zodiac figurine.
Each string is one of "ne", "ushi", "tora", "u", "tatsu", "mi", "uma", "hitsuji", "saru", "tori", "inu", "i".

Output

If such an arrangement is possible, output "YES" on one line; otherwise, output "NO" on one line.
Do not forget the newline at the end.

Sample

Sample 1
Input
12
ne
ushi
tora
u
tatsu
mi
uma
hitsuji
saru
tori
inu
i
Output
YES

All the figurines are of different types.
Any arrangement works.

Sample 2
Input
3
saru
saru
saru
Output
NO

However you arrange them, "saru" figurines end up next to each other.

Sample 3
Input
15
u
ushi
tora
tora
hitsuji
saru
saru
hitsuji
tatsu
hitsuji
ne
inu
hitsuji
u
mi
Output
YES

It is possible.

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