#abc217c. C - Inverse of Permutation

C - Inverse of Permutation

Score : 300300 points

问题描述

我们将长度为 NN 的序列,其中每个 1,2,,N1,2,\dots,N 各出现一次,称为长度为 NN 的排列。

给定一个长度为 NN 的排列 P=(p1,p2,,pN)P = (p_1, p_2,\dots,p_N),输出一个满足以下条件的长度为 NN 的排列 Q=(q1,,qN)Q = (q_1,\dots,q_N)

  • 对于每一个 ii (1iN)(1 \leq i \leq N)QQ 中的第 pip_i 个元素为 ii

可以证明存在唯一一个满足条件的 QQ

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

We will call a sequence of length NN where each of 1,2,,N1,2,\dots,N occurs once as a permutation of length NN.
Given a permutation of length NN, P=(p1,p2,,pN)P = (p_1, p_2,\dots,p_N), print a permutation of length NN, Q=(q1,,qN)Q = (q_1,\dots,q_N), that satisfies the following condition.

  • For every ii (1iN)(1 \leq i \leq N), the pip_i-th element of QQ is ii.

It can be proved that there exists a unique QQ that satisfies the condition.

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • (p1,p2,,pN)(p_1,p_2,\dots,p_N) is a permutation of length NN (defined in Problem Statement).
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

p1p_1 p2p_2 \dots pNp_N

Output

Print the sequence QQ in one line, with spaces in between.

q1q_1 q2q_2 \dots qNq_N

Sample Input 1

3
2 3 1

Sample Output 1

3 1 2

The permutation Q=(3,1,2)Q=(3,1,2) satisfies the condition, as follows.

  • For i=1i = 1, we have pi=2,q2=1p_i = 2, q_2 = 1.
  • For i=2i = 2, we have pi=3,q3=2p_i = 3, q_3 = 2.
  • For i=3i = 3, we have pi=1,q1=3p_i = 1, q_1 = 3.

Sample Input 2

3
1 2 3

Sample Output 2

1 2 3

If pi=ip_i = i for every ii (1iN)(1 \leq i \leq N), we will have P=QP = Q.

Sample Input 3

5
5 3 2 4 1

Sample Output 3

5 3 2 4 1

update @ 2024/3/10 09:36:41