#arc162b. [arc162_b]Insertion Sort 2
[arc162_b]Insertion Sort 2
Problem Statement
A permutation of is given.
Determine whether it is possible to rearrange in ascending order by performing the following operation at most times, and if possible, show one such sequence of operations.
- Choose integers and such that . Let be the sequence obtained by removing from . Replace with $(Q_1,\\ldots,Q_j, P_i, P_{i+1}, Q_{j+1},\\ldots,Q_{N-2})$.
Constraints
- is a permutation of .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
If cannot be rearranged in ascending order within operations, print No
. If it can be rearranged in ascending order, let be the number of operations, and be the chosen for the -th operation , and print them in the following format:
Yes
If there are multiple solutions, any of them will be considered correct.
Sample Input 1
5
1 4 2 3 5
Sample Output 1
Yes
1
3 1
Perform the operation with .
Then, , so you get .
Thus, can be rearranged in ascending order with one operation.
Sample Input 2
2
2 1
Sample Output 2
No
It can be proved that cannot be rearranged in ascending order within operations.
Sample Input 3
4
3 4 1 2
Sample Output 3
Yes
3
3 0
1 2
3 0
There is no need to minimize the number of operations.