CF1759G.Restore the Permutation
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A sequence of n numbers is called permutation if it contains all numbers from 1 to n exactly once. For example, the sequences [ 3,1,4,2 ], [ 1 ] and [ 2,1 ] are permutations, but [ 1,2,1 ], [ 0,1 ] and [ 1,3,4 ] — are not.
For a permutation p of even length n you can make an array b of length 2n such that:
- bi=max(p2i−1,p2i) for 1≤i≤2n
For example, if p = [ 2,4,3,1,5,6 ], then:
- b1=max(p1,p2)=max(2,4)=4
- b2=max(p3,p4)=max(3,1)=3
- b3=max(p5,p6)=max(5,6)=6
As a result, we made b = [4,3,6] .For a given array b , find the lexicographically minimal permutation p such that you can make the given array b from it.
If b = [ 4,3,6 ], then the lexicographically minimal permutation from which it can be made is p = [ 1,4,2,3,5,6 ], since:
- b1=max(p1,p2)=max(1,4)=4
- b2=max(p3,p4)=max(2,3)=3
- b3=max(p5,p6)=max(5,6)=6
A permutation x1,x2,…,xn is lexicographically smaller than a permutation y1,y2…,yn if and only if there exists such i ( 1≤i≤n ) that x1=y1,x2=y2,…,xi−1=yi−1 and xi<yi .
输入格式
The first line of input data contains a single integer t ( 1≤t≤104 ) — the number of test cases.
The description of the test cases follows.
The first line of each test case contains one even integer n ( 2≤n≤2⋅105 ).
The second line of each test case contains exactly 2n integers bi ( 1≤bi≤n ) — elements of array b .
It is guaranteed that the sum of n values over all test cases does not exceed 2⋅105 .
输出格式
For each test case, print on a separate line:
- lexicographically minimal permutation p such that you can make an array b from it;
- or a number -1 if the permutation you are looking for does not exist.
输入输出样例
输入#1
6 6 4 3 6 4 2 4 8 8 7 2 3 6 6 4 2 4 4 4 8 8 7 4 5
输出#1
1 4 2 3 5 6 1 2 3 4 -1 5 6 3 4 1 2 -1 1 8 6 7 2 4 3 5
说明/提示
The first test case is parsed in the problem statement.