#ABC470D. 逆排列与交换 / Inverse and Swap
逆排列与交换 / Inverse and Swap
Problem Statement
You are given a permutation of .
Process queries in order. There are two types of queries as follows:
1 x y: Swap the values of and .2: Construct the permutation of satisfying the following condition, and replace the values of with , respectively. (One can prove that such uniquely exists.)- for every integer satisfying .
Output the values of after processing all queries.
Constraints
- is a permutation of .
- for queries of type .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
$N$ $Q$
$P_1$ $P_2$ $\cdots$ $P_N$
$\mathrm{query}_1$
$\vdots$
$\mathrm{query}_Q$
Here, represents the -th query, and is given in one of the following two formats:
$1$ $x$ $y$
$2$
Output
Output the values of after processing all queries, separated by spaces, on one line.
5 5
2 1 3 5 4
1 2 4
2
1 2 3
1 3 4
2
4 5 2 1 3
At the point when each query has been processed, the values of are as follows:
- After processing the first query, .
- After processing the second query, .
- After processing the third query, .
- After processing the fourth query, .
- After processing the fifth query, .
7 4
3 7 5 6 4 2 1
2
2
2
2
3 7 5 6 4 2 1
10 8
7 3 2 4 8 5 10 9 1 6
2
1 4 10
1 6 9
2
1 9 10
1 3 10
2
1 4 6
3 10 2 8 6 7 1 5 9 4
- Source: AtCoder ABC 470 D
相关
在下列比赛中: