SP18247 IITWPC4D - Arrangement Validity

Description

n persons are standing in a line. Height of each person is between 1 and n and height of each person is distinct. You a given array A where A\[i\] denotes how many persons are before i\_th person having heights greater than H\[i\]. eg. For person 2, person 1 is considered before him. If A is given to be \[0, 1\] then one valid arrangements of height could be \[2, 1\] as number of persons having height > 1 before 2 are 1 because H\[1\] > H\[2\] You have to find out whether this array can be valid for some arrangement of persons. If you can uniquely do so, then find out the array H. Otherwise output -1.

Input Format

First line contains T : number of test cases. (1

Output Format

For each test case output single line If there is a unique way of H. Then print n space seprated integers in the line. Otherwise output -1. In starting of each test case also put "Test : testNumber" (without quotes). Note that there is a space before colon and one space after colon.