题目描述
Problem Description
Given a permutation \( p \) of numbers from \( 1 \) to \( n \), with indices starting from \( 1 \).
Exactly \( K \) times, you can choose any \( 1 \le i < n \) and swap \( p_i \) and \( p_{i+1} \). What is the lexicographically smallest permutation \( p \) after these swaps?
Input Format
The first line contains two non-negative integers \( n \) and \( K \), representing the number of elements in the permutation and the number of swaps, respectively.
The next line contains \( n \) integers describing the permutation \( p \).
Output Format
A single line containing \( n \) positive integers separated by spaces, describing the permutation after the swaps.
Sample Input and Output
Sample Input #1
5 2
2 1 4 3 5
Sample Output #1
1 2 3 4 5
Sample Input #2
5 3
5 4 3 2 1
Sample Output #2
2 5 4 3 1
Sample Input #3
5 6
5 4 3 2 1
Sample Output #3
1 3 5 4 2
Notes
This problem is a bundled test.
For all test cases, \( 1 \le n \le 5 \times 10^5 \) and \( 0 \le K \le 10^{12} \).
Detailed data ranges are as follows:
| Subtask Number | \( n \) | \( K \) | Score |
|---|---|---|---|
| 1 | \(\le 8\) | 30 | |
| 2 | \(\le 10^3\) | 30 | |
| 3 | \(\le 10^3\) | \(=10^{12}\) | 15 |
| 4 | \(\le 5 \times 10^5\) | 25 |
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分