103491: [Atcoder]ABC349 B - Commencement

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

Description

Score: $200$ points

Problem Statement

A string $S$ consisting of lowercase English letters is a good string if and only if it satisfies the following property for all integers $i$ not less than $1$:

  • There are exactly zero or exactly two different letters that appear exactly $i$ times in $S$.

Given a string $S$, determine if it is a good string.

Constraints

  • $S$ is a string of lowercase English letters with a length between $1$ and $100$, inclusive.

Input

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

$S$

Output

Print Yes if $S$ is a good string, and No otherwise.


Sample Input 1

commencement

Sample Output 1

Yes

For the string commencement, the number of different letters that appear exactly $i$ times is as follows:

  • $i=1$: two letters (o and t)
  • $i=2$: two letters (c and n)
  • $i=3$: two letters (e and m)
  • $i\geq 4$: zero letters

Therefore, commencement satisfies the condition of a good string.


Sample Input 2

banana

Sample Output 2

No

For the string banana, there is only one letter that appears exactly one time, which is b, so it does not satisfy the condition of a good string.


Sample Input 3

ab

Sample Output 3

Yes

Input

Output

分数:200分

问题描述

一个由小写字母组成的字符串$S$是一个好字符串,如果对于所有不小于1的整数$i$,满足以下条件:

  • 在$S$中恰好有0个或2个不同的字母出现恰好$i$次。

给定一个字符串$S$,判断它是否是好字符串。

限制条件

  • $S$是一个长度在$1$到$100$(含)之间的英文字母字符串。

输入

输入从标准输入按以下格式给出:

$S$

输出

如果$S$是好字符串,打印Yes;否则,打印No


样例输入1

commencement

样例输出1

Yes

对于字符串commencement,出现恰好$i$次的不同字母数量如下:

  • $i=1$: 两个字母 (ot)
  • $i=2$: 两个字母 (cn)
  • $i=3$: 两个字母 (em)
  • $i\geq 4$: 0个字母

因此,commencement满足好字符串的条件。


样例输入2

banana

样例输出2

No

对于字符串banana,只有1个字母(b)出现恰好1次,所以它不满足好字符串的条件。


样例输入3

ab

样例输出3

Yes

加入题单

上一题 下一题 算法标签: