103371: [Atcoder]ABC337 B - Extended ABC

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:17 Solved:0

Description

Score: $200$ points

Problem Statement

We define Extended A strings, Extended B strings, Extended C strings, and Extended ABC strings as follows:

  • A string $S$ is an Extended A string if all characters in $S$ are A.
  • A string $S$ is an Extended B string if all characters in $S$ are B.
  • A string $S$ is an Extended C string if all characters in $S$ are C.
  • A string $S$ is an Extended ABC string if there is an Extended A string $S_A$, an Extended B string $S_B$, and an Extended C string $S_C$ such that the string obtained by concatenating $S_A, S_B, S_C$ in this order equals $S$.

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 $S$ consisting of A, B, and C. If $S$ is an Extended ABC string, print Yes; otherwise, print No.

Constraints

  • $S$ is a string consisting of A, B, and C.
  • $1\leq|S|\leq 100$ ($|S|$ is the length of the string $S$.)

Input

The input is given from Standard Input in the following format:

$S$

Output

If $S$ 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 $3$, AAA, an Extended B string of length $3$, BBB, and an Extended C string of length $7$, CCCCCCC, in this order.

Thus, print Yes.


Sample Input 2

ACABABCBC

Sample Output 2

No

There is no triple of Extended A string $S_A$, Extended B string $S_B$, and Extended C string $S_C$ such that the string obtained by concatenating $S_A$, $S_B$, and $S_C$ in this order equals ACABABCBC.

Therefore, print No.


Sample Input 3

A

Sample Output 3

Yes

Sample Input 4

ABBBBBBBBBBBBBCCCCCC

Sample Output 4

Yes

Output

分数:200分

问题描述

我们定义扩展A字符串、扩展B字符串、扩展C字符串和扩展ABC字符串如下:

  • 如果字符串$S$中的所有字符都是A,则称字符串$S$是扩展A字符串。
  • 如果字符串$S$中的所有字符都是B,则称字符串$S$是扩展B字符串。
  • 如果字符串$S$中的所有字符都是C,则称字符串$S$是扩展C字符串。
  • 如果存在一个扩展A字符串$S_A$、一个扩展B字符串$S_B$和一个扩展C字符串$S_C$,使得按照这个顺序连接$S_A$、$S_B$、$S_C$得到的字符串等于$S$,则称字符串$S$是扩展ABC字符串。

例如,ABCAAAABBBCCCCCCC是扩展ABC字符串,但ABBAAACBBBCCCCCCCAAA不是。 注意,空字符串是扩展A字符串、扩展B字符串和扩展C字符串。

给你一个由ABC组成的字符串$S$。如果$S$是扩展ABC字符串,则输出Yes;否则,输出No

约束

  • $S$是一个由ABC组成的字符串。
  • $1\leq|S|\leq 100$($|S|$表示字符串$S$的长度)。

输入

输入通过标准输入给出,格式如下:

$S$

输出

如果$S$是扩展ABC字符串,则输出Yes;否则,输出No


样例输入1

AAABBBCCCCCCC

样例输出1

Yes

AAABBBCCCCCCC是一个扩展ABC字符串,因为它是一个扩展A字符串AAA(长度为3)、扩展B字符串BBB(长度为3)和扩展C字符串CCCCCCC(长度为7)按照这个顺序连接的结果。

因此,输出Yes


样例输入2

ACABABCBC

样例输出2

No

不存在一个扩展A字符串$S_A$、扩展B字符串$S_B$和扩展C字符串$S_C$,使得按照这个顺序连接$S_A$、$S_B$和$S_C$得到的字符串等于ACABABCBC

因此,输出No


样例输入3

A

样例输出3

Yes

样例输入4

ABBBBBBBBBBBBBCCCCCC

样例输出4

Yes

HINT

判断一个字符串是否由不多于一个A串、B串、C串构成?竟然还需要按顺序?

加入题单

算法标签: