Given a permutation π required to find π-1.
Output
Output π-1
Enter |
Output |
3
2 3 1
|
3 1 2
|
Parsing:
We enter N and start an array from 1 to N. Now we start reading this permutation - it is not necessary to store it, so it would be reasonable to enter each element into the same variable. Entering the i-th element, we put its ordinal number (i) in the array cell with a number equal to this number, i.e. for each element of a given permutation, we save its place in this permutation. Now we output the resulting array.