-
Notifications
You must be signed in to change notification settings - Fork 185
/
c.cc
43 lines (41 loc) · 919 Bytes
/
c.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// https://codeforces.com/contest/1315/problem/C
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using si = set<ll>;
int main() {
cin.tie(0), ios::sync_with_stdio(0);
ll t, n;
cin >> t;
while (t--) {
cin >> n;
si s;
for (int i = 1; i <= 2*n; i++) s.insert(i);
vi a(2*n), b(n), c(n), d(n+1);
for (int i = 0; i < n; i++) {
cin >> b[i];
c[i] = b[i];
s.erase(b[i]);
}
sort(c.begin(), c.end());
bool ok=1;
for (int i = 0, j = 1; i < n; i++, j+=2) {
if (c[i] > j) {
ok=0;
break;
}
}
if (!ok) cout << "-1\n";
else {
for (int i = 0; i < n; i++) {
a[2*i] = b[i];
int next = *lower_bound(s.begin(), s.end(), b[i]);
s.erase(next);
a[2*i+1] = next;
}
for (int i = 0; i < 2*n; i++)
cout << a[i] << " \n"[i==2*n-1];
}
}
}