C. Restoring Permutation
You are given a sequence b1,b2,…,bnb1,b2,…,bn. Find the lexicographically minimal permutation a1,a2,…,a2na1,a2,…,a2n such that bi=min(a2i−1,a2i)bi=min(a2i−1,a2i), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases tt (1≤t≤1001≤t≤100).
The first line of each test case consists of one integer nn — the number of elements in the sequence bb (1≤n≤1001≤n≤100).
The second line of each test case consists of nn different integers b1,…,bnb1,…,bn — elements of the sequence bb (1≤bi≤2n1≤bi≤2n).
It is guaranteed that the sum of nn by all test cases doesn't exceed 100100.
Output
For each test case, if there is no appropriate permutation, print one number −1−1.
Otherwise, print 2n2n integers a1,…,a2na1,…,a2n — required lexicographically minimal permutation of numbers from 11 to 2n2n.
Example
input
Copy
5 1 1 2 4 1 3 4 1 3 4 2 3 4 5 5 1 5 7 2 8
output
Copy
1 2 -1 4 5 1 2 3 6 -1 1 3 5 6 7 9 2 4 8 10
题意 : 给一组 长度为 n 的 b[i] , 让你找一组 长度 为 2n 的a[i] , 满足 b[i] = min(a[2*i-1 ] ,a[2*i] ) ,并且字典序最小 。
思路 : 贪心
其实就是在左边下面的图中填空,右边空白的要大于左边的数字,并且要先从 左边开始模拟我们填数的过程。