P7818 [RC-05] Permutation

Background

[Advertisement](http://119.27.163.117/problem/97)

Description

Given a permutation $p$ of $1\sim n$, with indices starting from $1$. You must perform **exactly** $K$ operations. In each operation, you may choose any $1\le i

Input Format

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

Output Format

Output one line with $n$ positive integers separated by spaces, describing the permutation after all swaps are completed.

Explanation/Hint

**This problem uses bundled testdata.** For all testdata, $1\le n\le 5\times 10^5$, $0\le K\le 10^{12}$. The detailed Constraints are shown in the table below: | Subtask ID | $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$ | Translated by ChatGPT 5