#P7818. [RC-05] 排列

[RC-05] 排列

Description

Given a permutation pp of 1n1\sim n, with indices starting from 11.

You must perform exactly KK operations. In each operation, you may choose any 1i<n1\le i<n and swap pip_i and pi+1p_{i+1}. After all swaps are done, what is the lexicographically smallest permutation pp?

Input Format

The first line contains two non-negative integers n,Kn,K, representing the number of elements in the permutation and the number of swaps.

The next line contains nn integers describing the permutation pp.

Output Format

Output one line with nn 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, 1n5×1051\le n\le 5\times 10^5, 0K10120\le K\le 10^{12}.

The detailed Constraints are shown in the table below:

Subtask ID nn KK Score
11 8\le 8 3030
22 103\le 10^3
33 =1012=10^{12} 1515
44 5×105\le 5\times 10^5 2525

Translated by ChatGPT 5