102172: [AtCoder]ABC217 C - Inverse of Permutation

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $300$ points

Problem Statement

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

  • For every $i$ $(1 \leq i \leq N)$, the $p_i$-th element of $Q$ is $i$.

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

Constraints

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

Input

Input is given from Standard Input in the following format:

$N$
$p_1$ $p_2$ $\dots$ $p_N$

Output

Print the sequence $Q$ in one line, with spaces in between.

$q_1$ $q_2$ $\dots$ $q_N$

Sample Input 1

3
2 3 1

Sample Output 1

3 1 2

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

  • For $i = 1$, we have $p_i = 2, q_2 = 1$.
  • For $i = 2$, we have $p_i = 3, q_3 = 2$.
  • For $i = 3$, we have $p_i = 1, q_1 = 3$.

Sample Input 2

3
1 2 3

Sample Output 2

1 2 3

If $p_i = i$ for every $i$ $(1 \leq i \leq N)$, we will have $P = Q$.


Sample Input 3

5
5 3 2 4 1

Sample Output 3

5 3 2 4 1

Input

题意翻译

给定一长度为 $N$ 的序列 $P$,$P$ 中的元素为 $1\sim N$ 的排列。 现根据如下规则构造一个长度为 $N$ 的序列 $Q$: - 序列 $Q$ 中的第 $P_i$ 个元素为 $i$。 易证得有且仅有一种序列 $Q$ 的构造方案。

Output

分数:300分

问题描述

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

  • 给定长度为$N$的排列$P = (p_1, p_2,\dots,p_N)$,输出一个长度为$N$的排列$Q = (q_1,\dots,q_N)$,满足以下条件。

对于每个$i$ $(1 \leq i \leq N)$,$Q$的第$p_i$个元素为$i$。

可以证明存在唯一一个满足条件的$Q$。

约束

  • $1 \leq N \leq 2 \times 10^5$
  • $(p_1,p_2,\dots,p_N)$是长度为$N$的排列(在问题描述中定义)。
  • 输入中的所有值都是整数。

输入

输入格式如下,从标准输入中给出:

$N$
$p_1$ $p_2$ $\dots$ $p_N$

输出

在一个行内输出序列$Q$,每个元素之间用空格分隔。

$q_1$ $q_2$ $\dots$ $q_N$

样例输入1

3
2 3 1

样例输出1

3 1 2

排列$Q=(3,1,2)$满足条件,如下所示。

  • 对于$i = 1$,我们有$p_i = 2, q_2 = 1$。
  • 对于$i = 2$,我们有$p_i = 3, q_3 = 2$。
  • 对于$i = 3$,我们有$p_i = 1, q_1 = 3$。

样例输入2

3
1 2 3

样例输出2

1 2 3

如果对于每个$i$ $(1 \leq i \leq N)$,$p_i = i$,则我们有$P = Q$。


样例输入3

5
5 3 2 4 1

样例输出3

5 3 2 4 1

加入题单

算法标签: