atcoder#ARC121C. [ARC121C] Odd Even Sort
[ARC121C] Odd Even Sort
Score : points
Problem Statement
Given is a sequence which is a permutation of . Initially, the -th term of is .
Your objective is to sort in ascending order in at most operations. In one operation, you make the following change on :
- In the -st, -rd, and subsequent odd-numbered operations, you choose an odd number between and (inclusive) to swap and .
- In the -nd, -th, and subsequent even-numbered operations, you choose an even number between and (inclusive) to swap and .
We can prove that the objective is always achievable under the Constraints of this problem. Find one sequence of operations that achieves the objective.
You will be given test cases and asked to solve each of them.
Constraints
- All values in input are integers.
- is a permutation of .
- In one input file, the sum of does not exceed .
Input
Input is given from Standard Input in the following format:
Each case is in the following format:
Output
For each of the test cases, in the order they are given, print your answer in the following format:
Here, represents the length of your sequence of operations, and represents the integer you choose in the -th operation.
Your output will be considered correct if, for every test case, your sequence of operations achieves the objective.
2
5
2 1 3 5 4
2
1 2
2
1 4
0
- Here is the description for the -st test case.- Choosing in the -st operation makes .
- Choosing in the -nd operation makes .
- Note that although is a valid sequence of operations, is not.
- Choosing in the -st operation makes .
- Choosing in the -nd operation makes .
- Note that although is a valid sequence of operations, is not.
- Also note that it is allowed to perform no operation, and it is not required to minimize the number of operations.