|
| 1 | +# Urban Construction |
| 2 | + |
| 3 | +### Description |
| 4 | + |
| 5 | +**Sjkmost** persuaded **Justin** to force his citizens to trip with zipline. However, the citizens are not strong enough and the citizens often fell from the zipline. Therefore, they decided to provide the citizens with some cable cars. Now **Sjkmost** is preparing the cable cars. |
| 6 | + |
| 7 | +There are $n$ cable cars on the cable, each has an index $a_i$. **Sjkmost** is trying to put them in order. |
| 8 | + |
| 9 | +**Sjkmost** can spend $c$ *justin* (a type of currency) to cut down a segment of rope of length $c$, rotate it and splice back. That is, he can spend $r−l+1$ *justin* to rotate the cable cars in an interval. |
| 10 | + |
| 11 | +**Sjkmost** has a budget of $2×10^7$ *justin*. He should sort the cable cars with some operations with a total cost no more than $2×10^7$ *justin*. But he is so good at sorting that this problem is too boring for him. |
| 12 | + |
| 13 | +**lhyyy**, who is not good at graph theory at all and got lost in **Justin**'s city, luckily met **Justin** at last. Now he doesn't know how to leave the city. If he can help sort the cable cars for **Sjkmost**, **Sjkmost** will tell him how to leave. However, **lhyyy** is not good at sorting as well. Can you help him? |
| 14 | + |
| 15 | +### Input Format |
| 16 | + |
| 17 | +The first line contains an integer $n (1≤n≤10^5)$, indicating the number of cable cars. |
| 18 | + |
| 19 | +The second line contains $n$ integers $a_1,a_2,...,a_n (1≤a_i≤10^9)$, indicating the indexes of the cable cars. |
| 20 | + |
| 21 | +### Output Format |
| 22 | + |
| 23 | +Output the operations in order. |
| 24 | + |
| 25 | +Each line contains two integers $l_i,r_i$ satisfying $1≤l_i≤r_i≤n$, which means rotating the interval $[l_i,r_i]$. |
| 26 | + |
| 27 | +Finally, output a line `-1 -1` denoting the end of the output. |
| 28 | + |
| 29 | +$∑r_i−l_i+1$ should not exceed $2×10^7$. |
| 30 | + |
| 31 | +**There must be an empty line at the end of the output!** |
| 32 | + |
| 33 | +**If there are multiple solutions, you can print any of them.** |
| 34 | + |
| 35 | +### Sample |
| 36 | + |
| 37 | +#### Sample Input1 |
| 38 | + |
| 39 | +``` |
| 40 | +4 |
| 41 | +1 3 2 4 |
| 42 | +``` |
| 43 | + |
| 44 | +#### Sample Output1 |
| 45 | + |
| 46 | +``` |
| 47 | +2 3 |
| 48 | +-1 -1 |
| 49 | +``` |
| 50 | + |
| 51 | +#### Sample Input2 |
| 52 | + |
| 53 | +``` |
| 54 | +4 |
| 55 | +4 3 2 1 |
| 56 | +``` |
| 57 | + |
| 58 | +#### Sample Output2 |
| 59 | + |
| 60 | +``` |
| 61 | +1 3 |
| 62 | +1 4 |
| 63 | +2 4 |
| 64 | +-1 -1 |
| 65 | +``` |
| 66 | + |
| 67 | +#### Sample Input3 |
| 68 | + |
| 69 | +``` |
| 70 | +10 |
| 71 | +11 4 5 1 4 1 91 9 8 10 |
| 72 | +``` |
| 73 | + |
| 74 | +#### Sample Output3 |
| 75 | + |
| 76 | +``` |
| 77 | +1 2 |
| 78 | +2 3 |
| 79 | +3 5 |
| 80 | +7 9 |
| 81 | +5 7 |
| 82 | +2 3 |
| 83 | +5 6 |
| 84 | +3 5 |
| 85 | +1 4 |
| 86 | +7 8 |
| 87 | +9 10 |
| 88 | +8 9 |
| 89 | +-1 -1 |
| 90 | +``` |
| 91 | + |
| 92 | +### Hint |
| 93 | + |
| 94 | +For 10% testcases, $n≤5$. |
| 95 | + |
| 96 | +For 20% testcases, $n≤500$. |
| 97 | + |
| 98 | +For 30% testcases, $n≤5×10^3$. |
| 99 | + |
| 100 | +For 50% testcases, $n≤1×10^4$. |
| 101 | + |
| 102 | +For 70% testcases, $n≤3×10^4, a_i≤n$. |
| 103 | + |
| 104 | +For 100% testcases, $n≤5×10^4$. |
0 commit comments