#ABC474C. 删除并追加 / Remove and Append
删除并追加 / Remove and Append
Problem Statement
You are given a permutation of . For in this order, perform the following operation.
- Remove the element with value from , and append it to the end of .
Find the value of each element of after performing the operations.
Constraints
- is a permutation of .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Output after performing the operations, in this order, separated by spaces, in one line.
4 2
2 4 3 1
3
2
4 1 3 2
Initially, . After the first operation, . After the second operation, .
3 3
1 2 3
1
1
1
2 3 1
2 5
2 1
1
1
2
2
1
2 1
- Source: AtCoder ABC 474 C
相关
在下列比赛中: