给定一个由正整数构成的数组 A[1...N],您需要按照以下方式将其升序排序:在每个操作中,选择任意两个不重叠的等长子数组并交换它们。也就是说,选择两个子数组 A[i...(i+k-1)] 和 A[j...(j+k-1)],使得 i+k-1<j 并交换 A[i] 和 A[j],A[i+1] 和 A[j+1] ... 以及 A[i+k-1] 和 A[j+k-1]。
我们如何以最有效的方式确定最小交换次数? 来源:https://www.hackerearth.com/problem/approximate/swap-and-sort/
Example:
For N=6
6 7 8 1 2 3
Only one operation is needed as after swapping (6 7 8) and (1 2 3 ) sub arrays
we can get 1 2 3 6 7 8 , that is sorted.
我们如何以最有效的方式确定最小交换次数? 来源:https://www.hackerearth.com/problem/approximate/swap-and-sort/