#abc377e. E - Permute K times 2
E - Permute K times 2
Score : points
问题陈述
给定一个排列 ,它是 的一个排列。
将执行 次以下操作:
- 对于 ,同时更新 为 。
打印所有操作完成后的 。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given a permutation of .
The following operation will be performed times:
- For , simultaneously update to .
Print after all operations.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
For the after all operations, print in this order, separated by spaces.
Sample Input 1
6 3
5 6 3 1 2 4
Sample Output 1
6 1 3 2 4 5
With each operation, changes as follows:
- After the first operation, is .
- After the second operation, is .
- After the third operation, is .
Thus, print 6 1 3 2 4 5
.
Sample Input 2
5 1000000000000000000
1 2 3 4 5
Sample Output 2
1 2 3 4 5
Since , does not change no matter how many operations are performed.
Sample Input 3
29 51912426
7 24 8 23 6 1 4 19 11 18 20 9 17 28 22 27 15 2 12 26 10 13 14 25 5 29 3 21 16
Sample Output 3
18 23 16 24 21 10 2 27 19 7 12 8 13 5 15 26 17 4 3 9 1 22 25 14 28 11 29 6 20