#P11190. 「KDOI-10」反回文串
「KDOI-10」反回文串
Description
We call a string with length palindrome if and only if for each , holds.
Given a string of length , you have to divide into several non-empty subsequences such that each of these subsequences is not palindrome, and maximize the number of subsequences.
Formally, you have to find a group of sequences such that:
- For each , let be the length of , then and ;
- For each , there is exactly one integer pair such that ;
- For each , let string , then is not palindrome.
You have to maximize , or determine there is no solution.
Specially, if your is not maximized, you may still get partial scores.
Input Format
Each test contains multiple test cases.
The first line of the input contains a single integer — the id of the test. represents that this is a sample test.
The second line contains a single integer — the number of test cases.
For each test case:
- The first line contains a single integer — the length of the string .
- The second line contains a string length . It is guaranteed that only contains lowercase English letters.
Output Format
For each test case:
- If there is no valid solution, print single string
Shuiniaoon the only line of output. - Otherwise, you have to:
- Print a sinle string
Huoyuon the first line; - Print an integer — the number of subsequences such that the string is divided into;
- For the -th line of the next lines :
- First, output an integer — the length of the -th subsequence;
- Next, output integers — the -th subsequence.
- Print a sinle string
Note that your output should satisfy all the constraints above, otherwise, you will get points in corresponding tests.
0
4
4
kdoi
7
ccccccc
7
sszcdjr
7
abacaca
Huoyu
2
2 1 2
2 3 4
Shuiniao
Huoyu
3
3 1 2 3
2 4 5
2 6 7
Huoyu
3
2 1 4
3 2 3 5
2 6 7
Hint
Sample 1 Explanation
In the first test case, it is obvious that the output satisfies the constraints. And:
- For the first subsequence, which is not palindrome.
- For the second subsequence, which is not palindrome.
As a result, this is a valid output. It can be proven that for this test case, the maximum possible value of is .
In the second test case, all of subsequences of are palindrome, so it is obvious that there is no solution.
Sample 2
See anti/anti2.in and anti/anti2.ans in the attachments.
This sample has test cases, all satisfying . Among them, the first to third test cases satisfy property A and the fourth to sixth test cases satisfy property B.
Scoring
This problem has tests and each worth points.
This problem is judged using Special Judge. Each test case might have multiple solutions and you only need to output one of them.
In each test, your score is the minimum number of points you receive in each test case. For each test case:
- If you incorrectly judged whether there is a solution or print an invalid solution, no points will be given.
- If you correctly judged whether there is a valid solution and print a valid solution:
- If is not maximized, points will be given.
- If is maximized, points will be given.
Constraints
For all the tests, it is guaranteed that:
- ;
- ;
- only contains lowercase English letters.
| Test Id | Special Properties | |
|---|---|---|
| - | ||
| B | ||
| - | ||
| A | ||
| B | ||
| - |
- Property A: It is guaranteed that is even and each type of letter in appears no more than times.
- Property B: It is guaranteed that only consists of
aorb.
How to Use the Checker
To help participants test their program, in the anti directory in the attachments, checker.cpp is provided. Participants can compile their codes and check whether the output is valid with it. Note that it is not exactly the same as the checker in final testing. You needn't care its content.
The compile commands are:
g++ −o checker -std=c++14 -O2 checker.cpp
You can use checker.cpp like this:
checker <input-file> <output-file>
Parameters <input-file> and <output-file> are respectively the input file and your output file.
If your output is out of range, the checker will report it and exit immediately. Otherwise, the checker will do the following things:
- In the -th line , output the detail of the -th test case.
- In the -th line, output the summary of this test.
As an example, for the input and output of the first sample, the checker will output the following things to the screen:
Test case 1: OK. Participant's answer is YES (Huoyu), and k=2.
Test case 2: OK. Participant's answer is NO (Shuiniao).
Test case 3: OK. Participant's answer is YES (Huoyu), and k=3.
Test case 4: OK. Participant's answer is YES (Huoyu), and k=3.
ok 4 / 4 test cases passed. (4 test cases)
If the output file is changed to this:
Huoyu
2
2 1 2
2 3 4
Huoyu
1
7 1 2 3 4 5 6 7
Huoyu
3
3 1 2 3
2 4 5
2 6 7
Huoyu
3
2 1 4
3 2 3 5
2 6 7
Then the checker will output the following things to the screen:
Test case 1: OK. Participant's answer is YES (Huoyu), and k=2.
Test case 2: Wrong answer. The string t obtained in the subsequence a[1] is palindrome.
Test case 3: OK. Participant's answer is YES (Huoyu), and k=3.
Test case 4: OK. Participant's answer is YES (Huoyu), and k=3.
wrong answer 3 / 4 test cases passed.
Note that checker.cpp will only check whether your output is valid, and will not:
- Check whether you correctly judge if there's a valid solution.
- Check whether is maximized.
As an example, if the output file of sample is changed to this:
Shuiniao
Shuiniao
Shuiniao
Shuiniao
checker.cpp will still report ok as a result.
京公网安备 11011102002149号