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 no 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 no 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.)
IT IS GUARANTEED THAT THE INPUT IS VALID AND THE PERMUTATION WILL BE UNIQUE.
First line of the input contains t, the no of testcases. (1<=t<=5)
Each testcase starts with N , the no of integers in the permutation.(1<=N<=100000)
Next line contains N space separated integers| A[i] (1<=i<=N) , representing the array A.
For each testcase , print N space separated integers in a single line, representing the permutation.
0 1 2
0 1 1 3 1
Output: 1 2
3 2 1
5 2 3 1 4
had a good time solving this:)CnC rocks:)BaZ rocks:)
why this problem is in Tutorial...??Last edit: 2018-01-01 01:05:20