No.349 Zodiac Figurines
タグ : / 解いたユーザー数 462
作問者 :
nmnmnmnmnmnmnm
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もしくは右上の雲マークをクリックしてアカウントを作成してください。