#K79097. Permutation Transformation
Permutation Transformation
Permutation Transformation
Luka is experimenting with permutations. A permutation of length \(n\) is an array containing each number from \(1\) to \(n\) exactly once. Given a permutation \(P\) (indexed from 1), define a new array \(Q\) of the same length such that:
[ Q_i = P[P_i] \quad \text{for } 1 \leq i \leq n ]
Your task is to compute and output the array \(Q\) given the permutation \(P\).
Example:
Input: 5 2 3 1 5 4</p>Output: 3 1 2 4 5
inputFormat
The first line contains an integer \(n\) (the length of the permutation). The second line contains \(n\) space-separated integers representing the permutation \(P\). It is guaranteed that \(P\) is a permutation of \(\{1, 2, \ldots, n\}\).
outputFormat
Output \(n\) space-separated integers representing the resulting permutation \(Q\) defined by \(Q_i = P[P_i]\) for \(1 \leq i \leq n\).
## sample5
2 3 1 5 4
3 1 2 4 5