CF1746C.Permutation Operations
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a permutation a of size n and you should perform n operations on it. In the i -th operation, you can choose a non-empty suffix of a and increase all of its elements by i . How can we perform the operations to minimize the number of inversions in the final array?
Note that you can perform operations on the same suffix any number of times you want.
A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. A suffix is several consecutive elements of an array that include the last element of the array. An inversion in an array a is a pair of indices (i,j) such that i>j and ai<aj .
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤104 ). The description of the test cases follows.
The first line of each test case contains a single integer n ( 1≤n≤105 ) — the size of the array.
The second line contains n distinct integers a1,a2,…,an ( 1≤ai≤n ), the initial permutation a .
It's guaranteed that the sum of n over all test cases does not exceed 2⋅105 .
输出格式
For each test case, print n integers x1,x2,…,xn ( 1≤xi≤n for each 1≤i≤n ) indicating that the i -th operation must be applied to the suffix starting at index xi . If there are multiple answers, print any of them.
输入输出样例
输入#1
4 4 1 2 3 4 5 1 3 2 4 5 3 2 3 1 1 1
输出#1
1 1 1 1 1 4 3 2 1 1 3 3 1
说明/提示
In the first test case one of the optimal solutions is to increase the whole array on each operation (that is, choose the suffix starting at index 1 ). The final array [11,12,13,14] contains 0 inversions.
In the second test case, a will be equal to [2,4,3,5,6] , [2,4,3,7,8] , [2,4,6,10,11] , [2,8,10,14,15] and [7,13,15,19,20] after the first, second, third, fourth, and fifth operations, respectively. So the final array a has zero inversions.