192 人解决，230 人已尝试。
267 份提交通过，共有 498 份提交。
2.1 EMB 奖励。
单点时限: 2.0 sec
内存限制: 256 MB
In datastruct class, the teacher gives partychen a simple sort question:
A permutation , , …, is a sequence containing each number from to exactly once. The result of applying permutation to an array of length is an array of length , where (0-based indices).
Given an array , find a permutation which has the effect of sorting the elements of in non-descending order, i.e., an order where each element is greater than or equal to the previous one. If there are several suitable permutations output the lexicographically smallest one.
The permutation , , …, is considered lexicographically smaller than the permutation , , …, if there is an index such that and the equation holds for all .
The first line of input gives the number of cases, (). test cases follow.
In each test case, there are two lines. The first line is a interger (), representing the numbers of array , and in the second line there are intergers.
Output the permutation as discrible above.
2 3 2 3 1 4 2 1 3 1
1 2 0 2 0 3 1
In case 1: The element that is originally at position goes to position . The elements originally at positions and go to positions and , respectively.
In case 2: There are two suitable permutations: and . The first one is lexicographically smaller.