#abc337b. B - Extended ABC

B - Extended ABC

Score: 200200 points

问题描述

我们按照以下方式定义扩展A字符串、扩展B字符串、扩展C字符串以及扩展ABC字符串:

  • 若字符串 SS 中的所有字符均为 A,则称 SS 为一个扩展A字符串。
  • 若字符串 SS 中的所有字符均为 B,则称 SS 为一个扩展B字符串。
  • 若字符串 SS 中的所有字符均为 C,则称 SS 为一个扩展C字符串。
  • 若存在一个扩展A字符串 SAS_A,一个扩展B字符串 SBS_B 以及一个扩展C字符串 SCS_C,且按顺序连接这三个字符串得到的结果等于 SS,则称 SS 为一个扩展ABC字符串。

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

现在给你一个由 ABC 组成的字符串 SS。如果 SS 是一个扩展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 SS is an Extended A string if all characters in SS are A.
  • A string SS is an Extended B string if all characters in SS are B.
  • A string SS is an Extended C string if all characters in SS are C.
  • A string SS is an Extended ABC string if there is an Extended A string SAS_A, an Extended B string SBS_B, and an Extended C string SCS_C such that the string obtained by concatenating SA,SB,SCS_A, S_B, S_C in this order equals SS.

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

Constraints

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

Input

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

SS

Output

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

Thus, print Yes.

Sample Input 2

ACABABCBC

Sample Output 2

No

There is no triple of Extended A string SAS_A, Extended B string SBS_B, and Extended C string SCS_C such that the string obtained by concatenating SAS_A, SBS_B, and SCS_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

update @ 2024/3/10 01:27:01