#P6339. [COCI 2007/2008 #2] TURBO
[COCI 2007/2008 #2] TURBO
Problem Description
Given a permutation of length containing , you need to sort it in increasing order. The sorting rules are as follows:
- Phase 1: Move the number to index by swapping it with adjacent numbers.
- Phase 2: Move the number to index in the same way.
- Phase 3: Move the number to index in the same way.
- Phase 4: Move the number to index in the same way.
And so on.
For each phase, output the number of swaps.
Input Format
The first line contains an integer .
The next lines each contain one integer, describing a permutation of .
Output Format
Output a total of lines. For each phase, output the number of swaps.
3
2
1
3
1
0
0
5
5
4
3
2
1
4
3
2
1
0
7
5
4
3
7
1
2
6
4
2
3
0
2
1
0
Hint
Constraints
- For of the testdata, .
- For of the testdata, .
Notes
This problem is translated from COCI2007-2008 CONTEST #2 T4 TURBO。
Translated by ChatGPT 5