一些原创题,不一定难,但尽量保证有趣(比如结构简洁等)
如果感兴趣,欢迎去题目链接提交~
Palindrome
Time limit :
Memory Limit :
Description
In this task, zhyh will give you a string \(S\) of lowercase letter, and you can perform the following operation several (possibly, zero) number of times: insert a pair of equal lowercase letters into an arbitrary position. More formally, in one operation you can choose an arbitrary letter \(c\) \((c\in \{\text{'a', 'b',...,'z'}\})\) and insert \([c,c]\) to any position in the array (at the beginning, between any two letters, or at the end).
Your task is to make it become a palindrome if it is possible. We call a string a palindrome if and only if it reads the same backwards and forwards.
In addition, for those cases solvable, the number of characters you insert should not exceed the length of the original string \(S\), which is proved to be achievable.
Input
The only line contains one string \(S\) of length \(n\) \((2\leq n\leq 10^6, n \text{ is even})\).
Output
If you cannot turn the string into a palindrome, just print NO in a line.
Otherwise print YES in a line first, then print the number of operations \(q\) \((0≤q≤\frac{n}{2})\) that you want to do in the second line. Then print the descriptions of operations.
In each of the following \(q\) lines print an integer \(p\) and a lowercase letter \(c\), which mean that you insert the letter \(c\) twice after \(p\) elements of the string. If the length of the string is \(m\) at present, then the condition \(0≤p≤m\) should be satisfied.
Example Input #1
abbccadd
Example Output #1
YES
2
1 c
0 d
Example Input #2
abc
Example Output #2
NO
Hint
Explanation of the first test case:
abbccadd → accbbccadd → ddaccbbccadd