This is the easy version of the problem. The only difference is the maximum number of operations you can perform. You can only make hacks if both versions are solved.
You are given an array $$$a$$$ of size $$$n$$$.
A cool swap walk is the following process:
You can perform at most $$$2n+4$$$ cool swap walks. Sort the array $$$a_1, a_2, \ldots, a_n$$$ in non-decreasing order. We can show that it's always possible to do so.
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains an integer $$$n$$$ ($$$2 \leq n \leq 500$$$) — the size of the array.
The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots ,a_n$$$ ($$$1 \le a_i \le n$$$) — the elements of the array.
It is guaranteed that the sum of $$$n^2$$$ over all test cases does not exceed $$$2.5 \cdot 10^5$$$.
For each test case, your output should consist of several lines:
321 232 1 343 2 3 4
0 2 RRDD DRDR 3 RRDRDD DRDDRR DDRRRD
In the first test case, the array $$$a$$$ is already non-decreasing, so you don't need to perform any walk.
In the second test case, $$$a=[2,1,3]$$$ initially.
In the first walk:
In the second walk:
After the two cool swap walks above, we get $$$a=[1,2,3]$$$, which is non-decreasing.
Name |
---|