Kotlin Heroes: Episode 11 |
---|
Finished |
You are given a permutation $$$p$$$ of length $$$n$$$.
You can perform operations of two types:
For each integer from $$$1$$$ to $$$(n-1)$$$, calculate the minimum number of operations required to remove that integer from the permutation.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 250\,000$$$).
The second line of each test case contains $$$n$$$ integers $$$p_1, p_2, \dots, p_n$$$ ($$$1 \le p_i \le n$$$). The array $$$p$$$ is a permutation.
Additional constraints on the input: the sum of $$$n$$$ over all test cases does not exceed $$$250\,000$$$.
For each test case, print $$$(n-1)$$$ integers. The $$$i$$$-th of them should be equal to the minimum number of operations required to remove $$$i$$$ from the permutation.
544 2 1 321 265 4 1 3 2 675 6 1 3 7 2 453 1 2 5 4
1 1 2 1 1 1 2 1 3 1 1 1 2 1 2 1 1 2 1
Name |
---|