P28511 [洛谷] [SEERC2019] Cycle String?
入门
题目描述

Problem Description

The Great Mage has given Alice and Bob a cyclic string of length $2 \cdot n$, which contains no repeated substrings of length $n$. In a cyclic string, character $s_{i+1}$ follows $s_i$, and $s_1$ follows $s_{2n}$.

Unfortunately, the devil has scrambled the order of the characters in the string. Help Alice and Bob restore the string to its original form that meets the above requirements.

Input Format

The first line contains a string $s$ of length $2 \cdot n \ (2 \leq 2\cdot n \leq 1 \ 000 \ 000)$, consisting only of lowercase letters.

Output Format

If it is possible to restore the string to meet the requirements, output NO on the first line; if it is not possible, output YES on the first line.

If there is a solution, output the restored string on the second line. If there are multiple solutions, output any one of them.

Sample Input and Output

Sample Input #1

cbbabcacbb

Sample Output #1

YES
abbabcbccb

Sample Input #2

aa

Sample Output #2

NO

Sample Input #3

afedbc

Sample Output #3

YES
afedbc

Notes

In the first sample, the substrings of the restored string are: abbab, bbabc, babcb, abcbc, bcbcc, cbccb, bccba, ccbab, babba.

Note that the answer in the first sample does not contain repeated substrings, but other answers also satisfy the problem requirements. Therefore, the answer is not unique, and the sample provides only one valid output.

In the second sample, it is not possible to restore the string to meet the requirements.

In the third sample, no operations are needed as it already meets the requirements.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
cbbabcacbb
样例输出
YES abbabcbccb