- Time limit: 1.00 s
- Memory limit: 512 MB
Your task is to find the minimum number of rounds and show how you can choose the pairs in each round.
The first input line has an integer $n$: the size of the array.
The second line has $n$ integers $x_1,x_2,\dots,x_n$: the initial permutation.
First print an integer $k$: the minimum number of rounds.
Then, for each round, print the number of swaps and the indices of each swap. You can print any valid solution.
- $1 \le n \le 2 \cdot 10^5$
5 2 1 3 4
Explanation: The inital array is $[5,2,1,3,4]$. After round $1$, the array becomes $[1,2,5,4,3]$. After round $2$, the array becomes $[1,2,3,4,5]$.