#P9746. 「KDOI-06-S」合并序列
「KDOI-06-S」合并序列
Problem Description
Given a sequence of length , .
You may perform several (possibly ) operations on this sequence. In each operation, you will:
- Choose three positive integers such that , and the value of does not exceed the current length of the sequence. Let .
- Then, delete to , and insert at the position where these numbers originally were. Note that the length of sequence will decrease by .
Determine whether it is possible to make the sequence contain only one number, that is, after all operations, the length of is . If it is possible, you also need to provide one valid operation plan.
Input Format
Read input from standard input.
This problem contains multiple test cases.
The first line contains a positive integer , indicating the number of test cases.
For each test case, the first line contains a positive integer , indicating the initial length of the sequence.
The second line contains integers , indicating the value of each element in the initial sequence.
Output Format
For each test case:
- If there exists a plan such that the sequence is reduced to only one number, output
Huoyuon the first line.- Then, on the second line output a non-negative integer , indicating the number of operations. You need to ensure .
- Then output lines, each containing three positive integers , indicating the three numbers you choose in this operation. You need to ensure and that does not exceed the current length of the sequence.
- Otherwise, output one line containing the string
Shuiniao.
2
5
3 3 1 4 5
9
3 4 6 5 4 5 1 2 4
Huoyu
2
3 4 5
1 2 3
Huoyu
3
1 3 4
2 3 4
1 2 4
Hint
[Sample Explanation #1]
For the first test case:
- In the first operation, , and the sequence becomes after the operation.
- In the second operation, , and the sequence becomes after the operation.
Thus, after two operations, the sequence contains only one number.
For the second test case:
- In the first operation, , , and the sequence becomes after the operation.
- In the second operation, , and the sequence becomes after the operation.
- In the third operation, , , and the sequence becomes after the operation.
Thus, after three operations, the sequence contains only one number.
[Sample #2]
See merge/merge2.in and merge/merge2.ans under the contestant directory.
This sample satisfies the constraints of test points .
[Sample #3]
See merge/merge3.in and merge/merge3.ans under the contestant directory.
This sample satisfies the constraints of test points .
[Constraints]
For all testdata, it is guaranteed that: , , .
| Test Point ID | |||
|---|---|---|---|
[Note]
denotes the bitwise XOR operation.
Please fully trust the constant factors and efficiency of the program.
Translated by ChatGPT 5