Problem F
Permutation
Input: Standard Input
Output: Standard Output
Given N and K find the N’th permutation of the integers from 1 to K when those permutations are lexicographically ordered. N starts from 0. Since N is very large N will be represented by a sequence of K non-negative integers S1, S2 ,…, Sk. From this sequence of integers N can be calculated with the following expression.
 
First line of the input contains T(≤10) the number of test cases. Each of these test cases consists of 2 lines. First line contains a integer K(1≤K≤50000). Next line contains K integers S1, S2 ,…, Sk.(0≤Si≤K-i).
For each test case output contains N’th permutation of the integers from 1 to K. These K integers should be separated by a single space.
| 432 1 031 0 042 1 1 041 2 1 0  | 3 2 12 1 33 2 4 12 4 3 1  | 
Problemsetter: Abdullah al
Mahmud
Special Thanks: Manzurur
Rahman Khan