Submit | All submissions | Best solutions | Back to list |
MOZSATLA - Sharmeen and the Lost Array |
Sharmeen loves array very much. Many days ago she wrote an array (of n elements and the index of this array is 1 based) in her notebook, but unfortunately she lost the notebook. She want to restore the array. The only clue she know that is if in any position(i) of the array (1<= i < n), the element in this position is greater than, equal or less than the next position(i+1) element.
Can you help her to restore the array?
Input
In the first line given an integer t (1 <= t <= 100), which is the number of test cases.
For each test case,
In the first line there will be given a positive integer n (1 <= n <= 105) which is the size of the lost array. In the next line there will be n - 1 integers Xi (0 <= Xi <= 2).
If, Xi = 0, then ith element is equal to (i+1)th element of the lost array.
If, Xi = 1, then ith element is less than (i+1)th element of the lost array.
If, Xi = 2, then ith element is greater than (i+1)th element of the lost array.
Output
For each test case you have to output the lost array in one line. If multiple solution exist then you have to print the lexicographically smallest one. Elements of the lost array must be greater than zero.
For better understanding see the sample input output.
Example
Input: 1
5
1 2 0 1
Output: 1 2 1 1 2
Added by: | Mozahid |
Date: | 2019-04-15 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
hide comments