CF1227B.Box

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Permutation pp is a sequence of integers p=[p1,p2,,pn]p=[p_1, p_2, \dots, p_n] , consisting of nn distinct (unique) positive integers between 11 and nn , inclusive. For example, the following sequences are permutations: [3,4,1,2][3, 4, 1, 2] , [1][1] , [1,2][1, 2] . The following sequences are not permutations: [0][0] , [1,2,1][1, 2, 1] , [2,3][2, 3] , [0,1,2][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 pp of length nn .

You don't know this permutation, you only know the array qq of prefix maximums of this permutation. Formally:

  • q1=p1q_1=p_1 ,
  • q2=max(p1,p2)q_2=\max(p_1, p_2) ,
  • q3=max(p1,p2,p3)q_3=\max(p_1, p_2,p_3) ,
  • ...
  • qn=max(p1,p2,,pn)q_n=\max(p_1, p_2,\dots,p_n) .

You want to construct any possible suitable permutation (i.e. any such permutation, that calculated qq for this permutation is equal to the given array).

输入格式

The first line contains integer number tt ( 1t1041 \le t \le 10^4 ) — the number of test cases in the input. Then tt test cases follow.

The first line of a test case contains one integer nn (1n105)(1 \le n \le 10^{5}) — the number of elements in the secret code permutation pp .

The second line of a test case contains nn integers q1,q2,,qnq_1, q_2, \dots, q_n (1qin)(1 \le q_i \le n) — elements of the array qq for secret permutation. It is guaranteed that qiqi+1q_i \le q_{i+1} for all ii ( 1i<n1 \le i < n ).

The sum of all values nn over all the test cases in the input doesn't exceed 10510^5 .

输出格式

For each test case, print:

  • If it's impossible to find such a permutation pp , print "-1" (without quotes).
  • Otherwise, print nn distinct integers p1,p2,,pnp_1, p_2, \dots, p_n ( 1pin1 \le p_i \le 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][1,3,4,5,2] is the only possible answer:

  • q1=p1=1q_{1} = p_{1} = 1 ;
  • q2=max(p1,p2)=3q_{2} = \max(p_{1}, p_{2}) = 3 ;
  • q3=max(p1,p2,p3)=4q_{3} = \max(p_{1}, p_{2}, p_{3}) = 4 ;
  • q4=max(p1,p2,p3,p4)=5q_{4} = \max(p_{1}, p_{2}, p_{3}, p_{4}) = 5 ;
  • q5=max(p1,p2,p3,p4,p5)=5q_{5} = \max(p_{1}, p_{2}, p_{3}, p_{4}, p_{5}) = 5 .

It can be proved that there are no answers for the second test case of the example.

首页