1740: Sorting With Permutation

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:3 解决:0

题目描述

A permutation p[0], p[1], ..., p[n-1] is a sequence containing each number from 0 to n-1 exactly once. The result of applying permutation p to an array a of length n is an array b of length n, where b[p[i]] = a[i] (0-based indices). Given an array a, find a permutation which has the effect of sorting the elements of a 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 return the lexicographically smallest one. The permutation p[0], p[1], ..., p[n-1] is considered lexicographically smaller than the permutation q[0], q[1], ..., q[n-1] if there is an index i such that p[i] < q[i] and the equation p[j] = q[j] holds for all j < i.

输入

The input contains a test, the first line of which is the number of elements, between 1 and 50 .There are specified elements, between 1 and 1000 in the second line. There is a space between each two number.

输出

The output contains a line, showing the exactly position of each element in the sorted non-descending sequence. Also there should be space between each two numbers.

样例输入 复制

4
2 1 3 1

样例输出 复制

2 0 3 1

提示

There are two suitable permutations - {2, 0, 3, 1} and {2, 1, 3, 0}. The first one is lexicographically smaller.

来源/分类