P26474 [AtCoder] Commutative Law
省选
题目描述

Problem Description

In some programming languages, for two strings s1 and s2, an operator + is defined to concatenate the strings. For example, when s1=a and s2=b, s1+s2=ab. However, unlike the operator + for numbers, the concatenation operator + does not satisfy the commutative law. For example, when s1=a and s2=b, s1+s2=ab, but s2+s1=ba, so the commutative law does not hold.

Yurafuna-kun devised an operator @ for two strings that satisfies the commutative law as follows:

  • s1@s2=min(s1,s2)+max(s1,s2)

Here, min and max represent lexicographical comparison, and + represents string concatenation. For example, when s1=a and s2=b, s1@s2=min(a,b)+max(a,b)=a+b=ab. Also, s2@s1=min(a,b)+max(a,b)=a+b=ab, so the commutative law holds.

Yurafuna-kun is very fond of the operator @ and enjoys playing a game where he decomposes strings into individual characters and then reconstructs the original string using only the operator @ and parentheses to change precedence. For example, the string apple can be reconstructed by expressions like ((a@(p@p))@l)@e or e@(((p@p)@a)@l). However, he realized that the string pen cannot be reconstructed after decomposition. Since he cannot play with strings that cannot be reconstructed, he needs to determine whether a given string can be reconstructed.

Given a string $ S $, determine if it can be reconstructed to its original form after decomposing it into individual characters using only the operator @ and parentheses.

Input Format

The input is given from the standard input in the following format:

$ S $

Output Format

Output Yes if $ S $ can be reconstructed, otherwise output No.

Sample Input and Output

Sample Input #1

abc

Sample Output #1

Yes

Sample Input #2

acb

Sample Output #2

Yes

Sample Input #3

bca

Sample Output #3

No

Sample Input #4

cba

Sample Output #4

No

Sample Input #5

aaba

Sample Output #5

No

Notes/Hints

Constraints

  • $ 1≦|S|≦3000 $ ($ |S| $ is the length of string $ S $)
  • $ S $ consists of only lowercase alphabets
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
abc
样例输出
Yes