P25296 [AtCoder] Palindrome-phobia
普及
题目描述

Problem Description

Snuke has a string \( S \) consisting only of the characters a, b, and c.

Snuke, who is afraid of palindromes, wants to rearrange the characters of \( S \) to avoid having any palindromic substring of length 2 or more. Determine if this is possible.

Input Format

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

\( S \)

Output Format

Output YES if it is possible, otherwise output NO.

Sample Input and Output

Sample Input #1

abac

Sample Output #1

YES

Sample Input #2

aba

Sample Output #2

NO

Sample Input #3

babacccabab

Sample Output #3

YES

Notes/Hints

Constraints

  • \( 1 \leq |S| \leq 10^5 \)
  • \( S \) does not contain any characters other than a, b, and c.

Sample Explanation 1

The original string contains the palindrome aba, but rearranging it to acba avoids any palindromic substrings of length 2 or more.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
abac
样例输出
YES