#P4402. [CERC2007] robotic sort 机械排序
[CERC2007] robotic sort 机械排序
Description
SORT is a company that provides sorting services with the motto: "Order is the most beautiful." Their job is to arrange certain items in order through a sequence of moves. The work rule allows only the following method to sort:

First find the position of the smallest-labeled item, denoted , then reverse the segment . Next find the position of the second smallest item, denoted , and reverse the segment ... and so on.
The figure shows an example with items. The smallest item is at position . Therefore, we first reverse the first items. The second smallest item is at the last position, so the next operation is to reverse items . The third step is to reverse items ...
There may be duplicate labels in the input. If multiple items have the same label, operate on them according to their original input order.
Input Format
The input has two lines. The first line contains an integer , the number of items.
The second line contains space-separated integers, the initial labels of the items.
Output Format
Output a single line with space-separated positive integers , where is the position of the -th smallest item before the -th operation.
Note: If before the -th operation the -th smallest item is already at the correct position , we reverse the segment (a single item).
6
3 4 5 1 6 2
4 6 4 5 6 6
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号