//sj 가 아직........
[문제요약] 소팅 기계가 수행할 수 있는 동작은 사이클릭 스왑이다.
4 , 1 , 5 , 2 , 3 순으로 된 나열에서 2 , 1 , 3 의 사이클릭 스왑이란
문제는 최소의 사이클릭 동작 수로 모든 나열을 정렬하는 게 문제이다. 답이 여러개인 경우 그 중 하나를 출력한다.
Sorting robot can only perform one specific operation: given the sequence of positions, robot can do a cyclic swap of boxes at those positions. Given sequence does not contain any position more than once.
For example, let's assume that the boxes are currently in order [4, 1, 5, 2, 3], and Mirko provides his robot with the sequence [2, 1, 3]. Robot will then rearrange the boxes so that the second box will go to position 1, first box will go to the position 3, and the third one will take the position 2. Obtained sequence of labels is [1, 5, 4, 2, 3].
Write a program that will sort the boxes using the minimal number of operations. Each sequence given to the robot can be arbitrary long.
NOTE: There may be multiple solutions and you can output any of them.
input 3 3 2 1 output 1 2: 3 1 input 5 2 3 1 5 4 output 2 3: 1 2 3 2: 5 4 input 5 1 2 3 4 5 output 0
출처:coci