#P7362. [eJOI 2020] XOR Sort (Day2)
[eJOI 2020] XOR Sort (Day2)
Description
Given a sequence of length , you can perform the following operation:
Choose a position and change to or .
You want to know how many operations are needed to make become:
- , a strictly increasing sequence, i.e. .
- , a non-strictly increasing sequence, i.e. .
Input Format
The first line contains two integers , representing the length of the sequence and the test point type.
The second line contains integers , representing the sequence.
Output Format
The first line contains an integer , representing the number of operations. You do not need to minimize ; you only need to satisfy .
The next lines each contain two integers , meaning to change to , where or .
5 1
3 2 8 4 1
3
1 2
4 3
5 4
5 2
4 4 2 0 1
3
3 2
4 3
5 4
Hint
Explanation for Sample 1
$$[3, 2, 8, 4, 1] \to [\mathbf 1, 2, 8, 4, 1] \to [1, 2, 8, \mathbf{12}, 1] \to [1, 2, 8, 12, \mathbf{ 13}]$$Explanation for Sample 2
$$[4, 4, 2, 0, 1] \to [4, 4, \mathbf6, 0, 1] \to [4, 4, 6, \mathbf6, 1] \to [4, 4, 6, 6, \mathbf7]$$Constraints
This problem uses bundled testdata.
- Subtask 1 (25 pts): , , and all are distinct.
- Subtask 2 (35 pts): , , and all are distinct.
- Subtask 3 (40 pts): , .
For of the testdata:
- .
- .
- .
This problem uses Special Judge.
Note
Translated from eJOI 2020 Day2 A XOR Sort。
Translated by ChatGPT 5
京公网安备 11011102002149号