#abc337b. B - Extended ABC
B - Extended ABC
Score: points
问题描述
我们按照以下方式定义扩展A字符串、扩展B字符串、扩展C字符串以及扩展ABC字符串:
- 若字符串 中的所有字符均为
A,则称 为一个扩展A字符串。 - 若字符串 中的所有字符均为
B,则称 为一个扩展B字符串。 - 若字符串 中的所有字符均为
C,则称 为一个扩展C字符串。 - 若存在一个扩展A字符串 ,一个扩展B字符串 以及一个扩展C字符串 ,且按顺序连接这三个字符串得到的结果等于 ,则称 为一个扩展ABC字符串。
例如,ABC、A 和 AAABBBCCCCCCC 都是扩展ABC字符串,但 ABBAAAC 和 BBBCCCCCCCAAA 不是。请注意,空字符串是一个扩展A字符串、扩展B字符串和扩展C字符串。
现在给你一个由 A、B 和 C 组成的字符串 。如果 是一个扩展ABC字符串,则输出 Yes;否则,输出 No。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We define Extended A strings, Extended B strings, Extended C strings, and Extended ABC strings as follows:
- A string is an Extended A string if all characters in are
A. - A string is an Extended B string if all characters in are
B. - A string is an Extended C string if all characters in are
C. - A string is an Extended ABC string if there is an Extended A string , an Extended B string , and an Extended C string such that the string obtained by concatenating in this order equals .
For example, ABC, A, and AAABBBCCCCCCC are Extended ABC strings, but ABBAAAC and BBBCCCCCCCAAA are not. Note that the empty string is an Extended A string, an Extended B string, and an Extended C string.
You are given a string consisting of A, B, and C. If is an Extended ABC string, print Yes; otherwise, print No.
Constraints
- is a string consisting of
A,B, andC. - ( is the length of the string .)
Input
The input is given from Standard Input in the following format:
Output
If is an Extended ABC string, print Yes; otherwise, print No.
Sample Input 1
AAABBBCCCCCCC
Sample Output 1
Yes
AAABBBCCCCCCC is an Extended ABC string because it is a concatenation of an Extended A string of length , AAA, an Extended B string of length , BBB, and an Extended C string of length , CCCCCCC, in this order.
Thus, print Yes.
Sample Input 2
ACABABCBC
Sample Output 2
No
There is no triple of Extended A string , Extended B string , and Extended C string such that the string obtained by concatenating , , and in this order equals ACABABCBC.
Therefore, print No.
Sample Input 3
A
Sample Output 3
Yes
Sample Input 4
ABBBBBBBBBBBBBCCCCCC
Sample Output 4
Yes
update @ 2024/3/10 01:27:01