#abc367e. E - Permute K times
E - Permute K times
Score : points
问题陈述
给定一个长度为 的序列 ,其中每个元素的值在 到 之间(包括 和 ),以及一个长度为 的序列 。
请打印对 执行以下操作 次的结果。
- 用 替换 ,使得 。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given a sequence of length where each element is between and , inclusive, and a sequence of length .
Print the result of performing the following operation times on .
- Replace with such that .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Let be the sequence after the operations. Print it in the following format:
Sample Input 1
7 3
5 2 6 3 1 4 6
1 2 3 5 7 9 11
Sample Output 1
7 2 3 5 1 9 3
In this input, and the initial sequence is .
- After one operation, the sequence is .
- After two operations, the sequence is .
- After three operations, the sequence is .
Sample Input 2
4 0
3 4 1 2
4 3 2 1
Sample Output 2
4 3 2 1
There may be cases where no operations are performed.
Sample Input 3
9 1000000000000000000
3 7 8 5 9 3 7 4 2
9 9 8 2 4 4 3 5 3
Sample Output 3
3 3 3 3 3 3 3 3 3