0124. Reversive Inversions

Input file name: invers.in
Output file name: invers.out
Time limit: 500 ms
Memory limit: 64 megabytes

Inversion table for a permutation P of numbers {1,2,…,N} is the table A=(Ai)1 ≤ i ≤ N which maps each i=Pj into the number of indices j' such that j' ≤ j but Pj'>Pj=i.

Given an inversion table for a permutation P, calculate the inversion table for the inverse permutation P-1.

Input file

File consists only of N integer numbers, delimited by spaces and newline characters, that form the inversion table of a permutation. You may assume that 1 ≤ N ≤ 5000.

Output file

Output N integer numbers separated by single spaces – inversion table for the inverse permutation. Leave no trailing spaces at the end of the single line of output.

If there are several possible answers, output any of them. If there are no answers, output the first N primes instead.

Examples:

invers.ininvers.out
5 0 1 3 2 1 01 5 1 3 2 0 0


Source: Petrozavodsk Summer 2003. Blitz Kontest, Monday, August 25
Author: Andrew Lopatin, Nick Durov

Discuss       Submit a solution



Printable version