#P3165. [CQOI2014] 排序机械臂
[CQOI2014] 排序机械臂
Description
To sort items of varying heights in nondecreasing order, engineers invented a sorting robotic arm. It follows a simple rule: in the first operation, find the position of the lowest item and reverse the items from the first item from the left up to (i.e., reverse the subarray ); in the second operation, find the position of the second lowest item and reverse the items from the second item from the left up to (i.e., reverse the subarray ); and so on. Eventually, all items will be sorted.

The figure above shows an example with six items. Before the first operation, the lowest item is at position , so the first through fourth items are reversed. Before the second operation, the second lowest item is at position , so the second through sixth items are reversed.
Your task is to write a program to determine the sequence of operations, namely, the position of the -th lowest item before each operation, so the robotic arm can execute them. Note that if there are items with equal height, their relative order must remain the same after sorting.
Input Format
The first line contains a positive integer , the number of items to sort.
The second line contains space-separated integers , the height of each item.
Output Format
Output one line containing space-separated integers .
6
3 4 5 1 6 2
4 6 4 5 6 6
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号