Codeforces Global Round 25
E
No Palindromes
Codeforces
2000
原题
← DF →
翻译中…

You are given a string $s$ consisting of lowercase Latin characters. You need to partition$^\dagger$ this string into some substrings, such that each substring is not a palindrome$^\ddagger$.

翻译中…

$^\dagger$ A partition of a string $s$ is an ordered sequence of some $k$ strings $t_1, t_2, \ldots, t_k$, such that $t_1 + t_2 + \ldots + t_k = s$, where $+$ here represents the concatenation operation.

翻译中…

$^\ddagger$ A string $s$ is considered a palindrome if it reads the same backwards as forwards. For example, $\mathtt{racecar}$, $\mathtt{abccba}$, and $\mathtt{a}$ are palindromes, but $\mathtt{ab}$, $\mathtt{dokibird}$, and $\mathtt{kurosanji}$ are not.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

翻译中…

Each test case contains a string $s$ consisting of lowercase Latin characters ($1 \le |s| \le 10^6$).

翻译中…

It is guaranteed that the sum of $|s|$ over all test cases does not exceed $10^6$.

翻译中…

Output

翻译中…

For each test case, print on one line "YES" if there exists a partition of $s$ whose parts are not palindromes, or "NO" if there is no such partition.

翻译中…

If the answer is "YES", on the second line, print an integer $k$ — the number of parts that $s$ needs to be partitioned to such that each part is not a palindrome. On the third line, print $k$ strings $t_1, t_2, \ldots, t_k$ representing such a partition. If there are multiple such partitions, print any of them.

翻译中…

Note

翻译中…

In the first test case, since $\mathtt{sinktheyacht}$ is already non-palindrome, the partition $[\mathtt{sinktheyacht}]$ is valid.

翻译中…

In the second test case, as any substring of the string $s$ is palindrome, there are no valid partitions.

翻译中…

In the third test case, another valid partition is $[\mathtt{uw},\mathtt{uo}, \mathtt{wou}, \mathtt{wu}]$.

翻译中…

样例

Input #1
3
sinktheyacht
lllllllll
uwuowouwu
Output #1
YES
1
sinktheyacht
NO
YES
3
uw uow ouwu
InputCopy OutputCopy
题目信息
题号
1951E
时间限制
2 s
内存限制
256 MB
标签
暴力
构造
分治
贪心
哈希
模拟
数学
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。