CF1227B.Box
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Permutation p is a sequence of integers p=[p1,p2,…,pn] , consisting of n distinct (unique) positive integers between 1 and n , inclusive. For example, the following sequences are permutations: [3,4,1,2] , [1] , [1,2] . The following sequences are not permutations: [0] , [1,2,1] , [2,3] , [0,1,2] .
The important key is in the locked box that you need to open. To open the box you need to enter secret code. Secret code is a permutation p of length n .
You don't know this permutation, you only know the array q of prefix maximums of this permutation. Formally:
- q1=p1 ,
- q2=max(p1,p2) ,
- q3=max(p1,p2,p3) ,
- ...
- qn=max(p1,p2,…,pn) .
You want to construct any possible suitable permutation (i.e. any such permutation, that calculated q for this permutation is equal to the given array).
输入格式
The first line contains integer number t ( 1≤t≤104 ) — the number of test cases in the input. Then t test cases follow.
The first line of a test case contains one integer n (1≤n≤105) — the number of elements in the secret code permutation p .
The second line of a test case contains n integers q1,q2,…,qn (1≤qi≤n) — elements of the array q for secret permutation. It is guaranteed that qi≤qi+1 for all i ( 1≤i<n ).
The sum of all values n over all the test cases in the input doesn't exceed 105 .
输出格式
For each test case, print:
- If it's impossible to find such a permutation p , print "-1" (without quotes).
- Otherwise, print n distinct integers p1,p2,…,pn ( 1≤pi≤n ). If there are multiple possible answers, you can print any of them.
输入输出样例
输入#1
4 5 1 3 4 5 5 4 1 1 3 4 2 2 2 1 1
输出#1
1 3 4 5 2 -1 2 1 1
说明/提示
In the first test case of the example answer [1,3,4,5,2] is the only possible answer:
- q1=p1=1 ;
- q2=max(p1,p2)=3 ;
- q3=max(p1,p2,p3)=4 ;
- q4=max(p1,p2,p3,p4)=5 ;
- q5=max(p1,p2,p3,p4,p5)=5 .
It can be proved that there are no answers for the second test case of the example.