TPGAME - The Permutation Game
YoMamaSoFat(Ankit), Kira(Akash) and Blackhood(Rohit) were playing Mini-Militia. Since YoMamaSoFat is a Mini-Militia pro,to defeat him Kira and Blackhood teamed up together for a battle vs YoMamaSoFat. But still Kira and Blackhood ended up on the losing side :/. So, Kira and Blackhood decided to humiliate YoMamaSoFat in return. Since YoMamaSoFat is a noob in coding, Kira and Blackhood asked one question each from YoMamaSoFat. First it was Blackhood's turn to ask. He gave YoMamaSoFat a permutation of N distinct integers from 1 to N and asked him to find for each integer (say K) in the permutation - the number of integers in its left and having value greater than K. YoMamaSoFat answered this instantly and gave Blackhood an array (say A) as the answer. Formally A[i], (1 <= i <= N) contains the number of elements which are greater than permutation[i] and in the left of the ith position in the permutation, where permutation[i] is the element at the ith position in the permutation. eg. for the permutation 5 4 3 1 2, the array would be 0 1 2 3 3. Since YoMamaSoFat was able to answer this, Kira aked him just the reverse of this problem, i.e. Kira gave him the array A and asked him to find the permutation corresponding to the array. Since YoMamaSoFat has always been winning, he wants to continue his winning legacy and asks you for help. (as he is not such a pro in coding as he is in Mini-Militia :p.)
HELP HIM!
It is guaranteed that the input is valid and the permutation will be unique.
Input
First line of the input contains t, the number of test cases. (1 <= t <= 5)
Each testcase starts with N, the number of integers in the permutation.(1 <= N <= 100000)
Next line contains N space separated integers| A[i] (1 <= i <= N), representing the array A.
Output
For each test case, print N space separated integers in a single line, representing the permutation.
Example
Input: 3 2 0 0 3 0 1 2 5 0 1 1 3 1 Output: 1 2 3 2 1 5 2 3 1 4
hide comments
miamimagna:
2024-11-03 18:30:12
I'm sorry bro I read blackhood as bakchood
|
|
sxie12:
2022-08-29 02:25:09
Same as IITWPC4D |
|
be1035016:
2018-01-18 19:08:41
had a good time solving this:)CnC rocks:)BaZ rocks:) |
|
amit_ranjan:
2018-01-01 01:04:56
why this problem is in Tutorial...?? Last edit: 2018-01-01 01:05:20 |
Added by: | null |
Date: | 2017-07-01 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | Own problem, Motivated by www.spoj.com/problems/SPCU |