| HPI 2026 Advanced |
|---|
| Finished |
There are $$$n$$$ fraternity houses at ASU, and the $$$i$$$-th frat house has an average frame value of $$$a_i$$$. Clavicular has decided to stream $$$n - k + 1$$$ times, with the $$$i$$$th stream starting from frat house $$$i$$$ and ending at frat house $$$i + k - 1$$$. Clavicular starts every stream with a frame value of $$$0$$$, but each time he visits a new frat house, his frame value will increase by $$$1$$$. Now, if Clavicular visits frat house $$$i$$$ while he has a frame value of $$$f$$$, he will get frame-mogged if $$$a_i \geq f$$$. Furthermore, if he gets frame-mogged at all $$$k$$$ houses in a given stream, he gets stream-mogged.
Formally, stream $$$i$$$ stream-mogs Clavicular if $$$a_{i + j - 1} \geq j$$$ for all $$$1 \leq j \leq k$$$.
As Clavicular's PR specialist, you do not want him to get stream-mogged too many times. However, you also don't want him to not get stream-mogged at all, as that would be a little too uninteresting. Hence, you've decided that he should be stream-mogged exactly $$$x$$$ times.
To achieve this goal, you can rearrange the frat houses however you want. Your job is to either output a suitable permutation of $$$a$$$ or report that the task is impossible.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \leq t \leq 10^4$$$). The description of each test case follows.
Each test case begins with three integers $$$n$$$, $$$k$$$ and $$$x$$$ ($$$1 \leq k \leq n \leq 5 \cdot 10^5$$$, $$$0 \leq x \leq n$$$).
The next line contains $$$n$$$ integers, $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq k$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5 \cdot 10^5$$$.
For each test case, if the task is impossible, output the single integer $$$0$$$.
Otherwise, output any permutation of $$$a$$$ that stream-mogs Clavicular exactly $$$x$$$ times.
55 3 03 3 2 1 36 3 03 3 2 1 3 34 3 23 2 1 34 3 03 3 3 24 3 43 3 3 2
3 3 1 3 201 2 3 300
For the first test case, none of the streams will stream-mog Clavicular. For instance, stream $$$1$$$ visits frat houses $$$1$$$, $$$2$$$, and $$$3$$$. This does not stream-mog Clavicular because although $$$a_1 = 3 \geq 1$$$ and $$$a_2 = 3 \geq 2$$$, $$$a_3 = 1 \lt 3$$$. Note that in this case, the original order of $$$a$$$ is also valid.
In the second case, it can be shown that all possible permutations will stream-mog Clavicular at least once. For instance, the given permutation stream-mogs Clavicular $$$1$$$ time during stream $$$4$$$, which visits frat houses $$$4$$$, $$$5$$$, and $$$6$$$.
| Name |
|---|


