#P8223. [WFOI - 02] I wanna moqueve(位移序列)
[WFOI - 02] I wanna moqueve(位移序列)
Background
It's my fiesta.
Before one match, kid was defeated on the map of WFOIR1; after one match, kid got up from where he fell.
kid succeeded; he is no longer who he used to be.
After finishing this problem, why not go solve this problem as well?
Problem Description
kid needs to sort a permutation of on a strange computer, and the next save point will only appear later.
kid can choose a number . Then, in each subsequent operation, kid may cyclically shift a subarray of length to the left or to the right (the leftmost / rightmost element moves to the rightmost / leftmost position). The shift amount is .
If kid performs more than operations, the permutation will explode and kid will fall again. Therefore, please tell kid a way to restore the sequence; leave the remaining operations to €€£!
Input Format
The input has lines:
The first line contains an integer , representing the length of the sequence.
The second line contains integers, representing the sequence .
Output Format
The output has lines.
The first two lines each contain one number, which are and respectively. is the number of operations.
The next lines each contain two numbers: the first is the left endpoint of the shifted interval, and the second is the direction, where means shifting left and means shifting right.
This problem uses . You will get accepted as long as the cyclic shift operations are correct.
3
2 3 1
2
2
2 0
1 0
5
4 2 3 5 1
3
3
3 1
1 1
2 0
Hint
-
Explanation for Sample :
Shift left on interval , the sequence becomes .
Shift left on interval , the sequence becomes .
-
Explanation for Sample :
Shift right on interval , the sequence becomes .
Shift right on interval , the sequence becomes .
Shift left on interval , the sequence becomes .
This problem uses bundled Subtasks.
| Subtask ID | Constraints and Notes |
|---|---|
| Subtask #0 () | |
| Subtask #1 () | |
| Subtask #2 () | |
| Subtask #3 () | |
| Subtask #4 () | |
| Subtask #5 () | |
| Subtask #6 () |
For of the testdata, , and the data guarantees that is a permutation of .
Translated by ChatGPT 5