#P7818. [RC-05] 排列
[RC-05] 排列
Description
Given a permutation of , with indices starting from .
You must perform exactly operations. In each operation, you may choose any and swap and . After all swaps are done, what is the lexicographically smallest permutation ?
Input Format
The first line contains two non-negative integers , representing the number of elements in the permutation and the number of swaps.
The next line contains integers describing the permutation .
Output Format
Output one line with positive integers separated by spaces, describing the permutation after all swaps are completed.
5 2
2 1 4 3 5
1 2 3 4 5
5 3
5 4 3 2 1
2 5 4 3 1
5 6
5 4 3 2 1
1 3 5 4 2
Hint
This problem uses bundled testdata.
For all testdata, , .
The detailed Constraints are shown in the table below:
| Subtask ID | Score | ||
|---|---|---|---|
Translated by ChatGPT 5
京公网安备 11011102002149号