The family of Darkness is once again in financial trouble! To clear off her debt, Darkness decided to go to the country of Elroad with Kazuma to earn some easy cash. However, after a certain someone almost caused the bankruptcy of Elroad, all the luck based games have been replaced with skill based games! Here's the nearest one they found which offers quite a fortune:
The dealer will give you an array
of size containing a permutation of the numbers from to . He allows you to perform the following operation on it: Select a subarray from index
to . Consider an array , containing the elements sorted in increasing order. For all from to , swap the position of elements and in . In other words, swap the smallest element of the subarray with the largest element of the subarray, the second smallest element of the subarray with the second largest element of the subarray, and so on, until you reach the median of the subarray. You win the game if you manage to sort
in increasing order using no more than operations.
Please help Darkness write a program to beat the game for her!
Input Specification
The first line will contain
The next line will contain
Output Specification
On the first line output one integer
Then output
Note: You do not need to find the shortest sequence of operations to sort the array. If there are multiple valid solutions, output any of them. Also, it can be proven that it is always possible to sort the array using no more than
Constraints
For all subtasks:
All
Subtask 1 [20%]
Subtask 2 [30%]
Subtask 3 [50%]
Sample Input
7 98
7 5 4 6 2 3 1
Sample Output
4
2 4
2 3
1 7
5 6
Explanation
First you perform the operation on the subarray
Then you perform the operation on the subarray
Then you perform the operation on the entire array. This swaps the following pairs:
Finally you perform the operation on the subarray
Since the final array is sorted in increasing order using no more than
Note that the sample output is not the only possible output which will receive AC
for this case.
Comments