atcoder#ASAPORO2B. Many Swaps Sorting
Many Swaps Sorting
Score : points
Problem Statement
Snuke has a sequence , which is a permutation of . The -th element (-indexed) in is .
He can perform kinds of operations labeled any number of times in any order. When the operation labeled is executed, the procedure represented by the following code will be performed:
for(int i=k;i<N;i++)
swap(p[i],p[i-k]);
He would like to sort in increasing order using between and operations (inclusive). Show one such sequence of operations. It can be proved that there always exists such a sequence of operations under the constraints in this problem.
Constraints
- is a permutation of .
Partial Scores
- In the test set worth points, .
- In the test set worth another points, .
Input
Input is given from Standard Input in the following format:
Output
Let be the number of operations in your solution. In the first line, print . In the -th of the following lines, print the label of the -th executed operation. The solution will be accepted if is at most and is in increasing order after the execution of the operations.
5
4 2 0 1 3
4
2
3
1
2
- Each operation changes as shown below:
9
1 0 4 3 5 6 2 8 7
11
3
6
1
3
5
2
4
7
8
6
3