

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
正整数 と、長さ の または からなる数列 が与えられます。
長さ の英大文字のみからなる文字列 であって、以下の操作を 回以上好きな回数行うことで に が含まれないようにできるものを 良い文字列 と呼びます。ここで、 で の 文字目を表し、 とします。
- 次のうちどちらかを選び、実行する。
- なる整数 であって
A
、R
、C
となるものを選び、 を に置き換える。 - なる整数 であって
A
、R
、C
となるものを選び、 を に置き換える。
- なる整数 であって
良い文字列が存在するか判定してください。
制約
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
出力
良い文字列が存在するならば Yes
と、存在しないならば No
と出力せよ。
正誤判定器は大文字と小文字を区別せず、どちらも受理する。例えば、答えが Yes
となるときに yes
や YES
、yEs
などと出力しても正解と判定される。
入力例 1Copy
12 0 1 0 1 1 1 1 0 1 1 1 0
出力例 1Copy
Yes
例えば RARCARCCRAGC
は良い文字列です。以下のように操作することで、 の全ての要素を にすることが可能であるからです。
- はじめ、 である。
- として前者の操作をする。 となる。
- として前者の操作をする。 となる。
- として後者の操作をする。 となる。
- として後者の操作をする。 となる。
良い文字列が存在するので、Yes
と出力してください。
入力例 2Copy
3 0 0 0
出力例 2Copy
No
良い文字列は存在しません。
入力例 3Copy
29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
出力例 3Copy
Yes
操作するまでもなく に は含まれていないので、英大文字からなる長さ の文字列はすべて良い文字列です。
Score : points
Problem Statement
You are given a positive integer and a sequence of length , consisting of and .
We call a string of length , consisting only of uppercase English letters, a good string if it is possible to perform the following operation any number of times (possibly zero) so that the sequence contains no . Here, denotes the -th character of , and we define , , and .
- Perform one of the following operations:
- Choose an integer with such that
A
,R
, andC
, and replace each of and with . - Choose an integer with such that
A
,R
, andC
, and replace each of and with .
- Choose an integer with such that
Determine whether there exists a good string.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
If there exists a good string, print Yes
; otherwise, print No
.
The judge is case-insensitive; for example, if the correct answer is Yes
, outputs such as yes
, YES
, or yEs
will also be accepted.
Sample Input 1Copy
12 0 1 0 1 1 1 1 0 1 1 1 0
Sample Output 1Copy
Yes
For example, RARCARCCRAGC
is a good string. This is because it is possible to change all elements of to by performing the following operations:
- Initially, .
- Perform the first operation with . Then, .
- Perform the first operation with . Then, .
- Perform the second operation with . Then, .
- Perform the second operation with . Then, .
Since there exists a good string, output Yes
.
Sample Input 2Copy
3 0 0 0
Sample Output 2Copy
No
Good strings do not exist.
Sample Input 3Copy
29 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Sample Output 3Copy
Yes
Since already contains no , every string of length consisting of uppercase English letters is a good string.