Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int mpow(int base, int exp);
void solve() {
long long int n;
cin >> n;
vector<long long int> v(n);
vector<long long int> cnt(2 * n + 1, 0);
for (long long int i = 0; i < (n); i++) {
cin >> v[i];
cnt[v[i]]++;
}
vector<long long int> out;
for (long lon... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | t = int(input())
for _ in range(t):
n = int(input())
l = list(map(int,input().split()))
done = l[::]
result = []
for i in range(n):
val = l[i]
flag = 0
for j in range(val+1,2*n+1):
if(j not in done):
done.append(j)
result.extend([va... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | t = int(input())
for _ in range(t):
n = int(input())
a = [int(x) for x in input().split()]
b = [None]*(2*n)
c = set(a)
d = set(range(1, 2*n+1))
for i in range(len(a)):
x = a[i]+1
while x in c:
x += 1
else:
q = 2*i
w = 2*i+1
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | for _ in range(int(input())):
n = int(input())
b = list(map(int, input().split()))
a = [-1] * 2 * n
for x in range(1, 2 * n + 1):
if x in b:
i = 2 * b.index(x)
a[i] = x
else:
i = -1
for j in range(0, 2 * n, 2):
if a[j] != ... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
int main() {
int i, j, k, t, n, l, largest_element;
scanf("%d", &t);
int result[t][200];
int largest_element_array[t];
for (i = 0; i < t; i++) {
int count = 0;
scanf("%d", &n);
largest_element = 2 * n;
largest_element_array[i] = largest_element;
int array_given[n];... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | t = int(input())
for i in range(t):
n = int(input())
b = list(map(int, input().split()))
a = [0 for i in range(n+n)]
vis = [0 for i in range(n+n+1)]
for i in range(n):
a[2*i] = b[i]
vis[b[i]] = 1
ans = 1
for i in range(n):
ok = 0
for j in range(b[i]+1, n+n+1):
if vis[j] == 1:
continue
a[2*i+1] ... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int f(map<int, int> &mp, int b[], int n, int l) {
bool x = 0;
for (int j = l + 1; j <= 2 * n; j++) {
if (!mp[j]) {
mp[j] = 1;
x = 1;
return j;
}
}
return 0;
}
int main() {
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
in... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, p = 0;
cin >> n;
int a[210], b[105], maxm = 0;
for (int i = 1; i <= n; i++) cin >> b[i];
bool g[210];
memset(g, false, sizeof(g));
for (int i = 1; i <= 2 * n; i += 2) a[i] = b[(i + 1) / 2],... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int INF = 1e18;
void solve() {
long long int n;
cin >> n;
long long int a[n], b[2 * n];
for (long long int i = 0; i < n; i++) cin >> a[i];
set<long long int> s;
for (long long int i = 1; i < 2 * n + 1; i++) s.in... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | /* / οΎοΎβ β β β β β β β β β β β γ
/ )\β β β β β β β β β β β β Y
(β β | ( Ν‘Β° ΝΚ Ν‘Β°οΌβ β(β γ
(β οΎβ Y βγ½-γ __οΌ
| _β qγ| γq |/
(β γΌ '_δΊΊ`γΌ οΎ
β |\ οΏ£ _δΊΊ'彑οΎ
β )\β β qβ β /
β β (\β #β /
β /β β β /α½£====================D-
/β β β /β \ \β β \
( (β )β β β β ) ).β )
(β β )β β β β β ( | /
|β /β β β β β β | /
[_] β β β β β [___] */
// Main Code at the Bottom
import ... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write
mod=10**9+7
def ni():
return int(raw_input())
def li():
return map(int,raw_input().split())
def pn(n):
stdout.write(str(n)+'\n')
def... | PYTHON |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | for t in range(int(input())):
n = int(input())
b = list(map(int,input().split()))
a = [0]*(2*n+1)
res = []
f = True
for i in b:
a[i] = 1
for i in b:
# print("bv",i)
res.append(i)
val = 0
# print("A",a)
for j in range(i,2*n+1):
if a[... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | for _ in range(int(input())):
n=int(input())
b=list(map(int,input().split()))
d={}
for i in range(1,2*n+1):
d[i]=1
for i in b:
d[i]=0
a=[]
for i in b:
a.append(i)
z=i
for j in range(z+1,2*n+1):
if d[j]:
z=j
d... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | from sys import stdin
input = stdin.readline
def mp():return map(int,input().split())
def it():return int(input())
for _ in range(it()):
n=it()
l=list(mp())
v=[]
flag=0
for i in range(n):
v.append(l[i])
k=l[i]
while k in v or k in l:
k+=1
if k>2*n:
# print(-1)
flag=1
break
v.append(k)
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import sys
#input=sys.stdin.readline
t=int(input())
while t:
t-=1
n=int(input())
b=list(map(int,input().split()))
l=[i for i in range(1,2*n+1) if i not in b]
ans=[]
k=0
for i in range(n):
c=0
ans.append(b[i])
for j in range(n):
if l[j]>b[i] and l[j] not in... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
vector<int> solve(int N, const vector<int>& B) {
vector<int> pos(2 * N + 1, -1);
for (int i = 0, _n = (N); i < _n; ++i) {
int x = B[i];
pos[x] = i;
}
set<int> missing;
for (int n = (1), _b = (2 * N); n <= _b; ++n) {
if (pos[n] < 0) missing.insert(n);
... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 |
import java.util.HashSet;
import java.util.Scanner;
public class B16 {
static int max = 11;
public static void main(String[] args) {
Scanner nik = new Scanner(System.in);
int t = nik.nextInt();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < t; i++) {
}
A: while (t-- > 0) {
int n = ni... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
istream::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int q;
cin >> q;
for (; q > 0; q--) {
int n;
cin >> n;
int b[n];
bool mk[n + n + 10];
for (int i = 0; i <= n + n; i++) mk[i] = 0;
for (int ... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | for _ in range(int(input())):
n=int(input())
b=[int(x) for x in input().split()]
a=[]
for i in range(n):
a.append(b[i])
k=b[i]
while(k in a or k in b):k+=1
if(k>2*n):print(-1);break
a.append(k)
else:
print(*a) | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long INF = 1 << 28;
const double pi = acos(-1.0);
int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};
int dir[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};
int knight[8][2] = {1, 2, 1, -2, 2, 1, 2, -1, -1, 2, -1, -2, -2, 1, -2, -1};
const long double EPS = 1e-7;
long long gcd(lo... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long power(long long a, long long b, long long m = mod) {
long long x = 1;
while (b) {
if (b & 1) {
x = 1ll * x * a % m;
}
a = 1ll * a * a % m;
b /= 2;
}
return x;
}
const int N = 1e5 + 9;
signed main() {
i... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import java.util.*;
import java.io.*;
public class c {
static boolean debug = false;
public static void main(String[] args) {
FS in = new FS(System.in);
PrintWriter out = new PrintWriter(System.out);
int numT = in.nextInt();
for(int t=0; t<numT; t++) {
int n = in.nextInt();
int[]... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
const long long MX = 1e18, N = 1e4 + 10;
const double PI = 3.141592653589793238;
using namespace std;
long long n, m, ans[N], a[N], t;
map<int, int> mp;
int main() {
cin >> t;
while (t--) {
cin >> n;
bool yes = true;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
++mp[a... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | t = int(input())
while t:
t += -1
n = int(input())
l = list(map(int, input().split()))
check = [0] * ((2 * n) + 1)
ans = [0] * (2 * n)
for i in range(0, 2 * n, 2):
ans[i] = l[i // 2]
check[ans[i]] = 1
# print(ans)
c = 1
for i in range(0, 2 * n, 2):
chintu = 0
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | from bisect import bisect_right
import sys
input = sys.stdin.readline
for ti in range(int(input().strip())):
n = int(input().strip())
b = [int(x) for x in input().strip().split()]
n = list(range(1, 2*n+1))
ans = []
for bi in b:
n.remove(bi)
for bi in b:
ai = bisect_right(n, bi)
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 |
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Round623C {
public static void solve() {
int t = s.nextInt();
outer:while(t-- >0) {
int n = s.nextInt();
int[] arr = new int[n];
... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | # cook your dish here
n=int(input())
while(n):
n=n-1
a=int(input())
b=list(map(int,input().split()))
c=[True for x in range(2*a+1)]
for x in b:
c[x]=False
ans=[]
get=True
for i in range(a):
flag=False
k=b[i]
while(k<2*a+1):
if c[k]==True:
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e2 + 10;
bool mark[maxn];
int ans[maxn];
int main() {
ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
bool flag = true;
memset(mark, false, sizeof(mark));
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import sys
from collections import Counter
def solve(N, B):
counts = Counter(B)
if any(v > 1 for v in counts.values()):
return -1
# Want smallest permutation that is element-wise greater than B
C = []
for x in range(1, 2 * N + 1):
if x not in counts:
C.append(x)
# ... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int Search(vector<long long int> v1, long long int x1) {
long long int j;
for (j = 0; j < v1.size(); j++) {
if (x1 == v1[j]) {
return j;
} else {
continue;
}
}
return -1;
}
int Search2(long long int v[], long long int x, long long int n) {
... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int b, c = 0, sum = 0, i = 0, s, j, n, d = 0, q = 0, e, f, t = 0, x,
h, l = 0, k = 0, x1, x2, y1, y2, m;
cin >> t;
vector<long long int> v;
vector<long long int> a;
vector<long long int> z;
map<long long int, long long i... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
const long long dx[8] = {-1, 0, 1, 0, -1, 1, 1, -1},
dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long long kdx[8] = {-2, -1, 1, 2, 2, 1, -1, -2},
kdy[8] = {1, 2, 2, 1, -1, -2, -2, -1};... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
bool compare(string &s1, string &s2) { return s1.size() < s2.size(); }
string lower(string second) {
transform(second.begin(), second.end(), second.begin(), ::tolower);
return second;
}
string upper(string second) {
transform(second.begin(), second.end(), second.begin... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import java.util.*;
public class RestoringPermutation {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int n = sc.nextInt();
int b[] = new int[n];
int a[] = new int[n*2];
int r[] = new int[n*2];
boolean bool = false;
for(int i... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | t = int(input())
for i in range(t):
n = int(input())
b = list(map(int,input().split()))
l = [i+1 for i in range(2*n)]
q = sorted(b)
ans = True
ansList = []
count = 0
if q[0]!=1:
print(-1)
continue
for i in range(1,2*n-1):
if i not in q and i+1 not in q:
if count == 0:
ans = False
break
else... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | for _ in range(int(input())):
l = int(input())
arr = [int(h) for h in input().strip().split(' ')]
newarr = []
flag=True
for i in range(2*l):
if i%2==0:
newarr.append(arr[i//2])
else:
num = newarr[-1]
while num<=2*l:
if (num in newar... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import java.io.*;
import java.util.*;
public class C implements Runnable {
boolean judge = false;
FastReader scn;
PrintWriter out;
String INPUT = "";
void solve() {
int t = scn.nextInt();
here: while(t-- > 0) {
int n = scn.nextInt();
int[] b = scn.nextIntArray(n);
int[] a = new int[2 * n];
TreeSe... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | def solve(m, b):
d=dict()
y=dict()
for i in range(m):
d[b[i]]=0
for k in d.keys():
x=k+1
while x in d.keys() or x in y.keys():
x+=1
if (x>2*m):
return -1
d[k]=x
y[x]=k
for i in range(m):
print(b[i], d[b[i]]... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | T=int(input())
for i in range(T):
N=int(input())
l=[0]*(N*2+1)
f=0
c=0
b=[int(x) for x in input().split()]
for j in range(0,len(b)):
c=c+1
l[c]=b[j]
c=c+1
if b.count(b[j]+1)==1 or l.count(b[j]+1)==1:
m=b[j]+1
while(True):
m=... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | I=input
for _ in[0]*int(I()):
I();b=*map(int,I().split()),;s={*range(2*len(b)+1)}-{*b};a=[];i=1
try:
for x in b:y=min(s-{*range(x)});s-={y};a+=x,y;i+=2
except:a=-1,
print(*a) | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import java.util.*;
import java.io.*;
public class Solution{
static long mod=998244353 ;
static boolean f=true;
static class pair implements Comparable<pair>{
int a,b,c;
pair(int x,int y,int z){
a=x;b=y;c=z;
}
public int compareTo(pair t){
if(c<t.c) ... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | // package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class BV3 {
public static void main(String[] Args){
FastReader scan=new FastReader();
int t=scan.nextInt();
while(t-->0){
int n=scan.next... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | cases=int(input())
final=[]
for _ in range(cases):
n=int(input())
mm=[]
flag=0
c=list(map(int,input().split()))
v=list(set(list(range(1,2*len(c)+1)))-set(c))
mm=[]
for i in range(len(v)):
r=c[i]
try:
q=min([v[i] for i in range(len(v)) if v[i]>r])
mm.ap... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t;
cin >> t;
while (t--) {
long long vis[205] = {0};
long long n, c = 0;
cin >> n;
long long a[n];
vector<long long> b;
for (long long i = 0; i < n; i++) {
cin >>... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import java.util.Scanner;
public class C {
public static void main(String[] args) {
new C();
}
public C() {
Scanner sc = new Scanner(System.in);
int amountT = sc.nextInt();
for (int task = 0; task < amountT; task++) {
int n = sc.nextInt();
int[] b = new int[n];
boolean[] done = new boolean[2 * n... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | from bisect import bisect_left
def main():
for _ in range(int(input())):
n, res = int(input()), []
l = list(map(int, input().split()))
r = sorted(set(range(1, n * 2 + 1)) - set(l))
try:
for a in l:
res += a, r.pop(bisect_left(r, a + 1))
print... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
int b[]=new int[n];
Set<Integer> set=new HashSet<>();
for(int i=0;i<n;i... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import javax.swing.JInternalFrame;
public class Main
{
public static void main(String[] args) throws IOException
{
StreamToken... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import java.io.*;
import java.util.*;
public class Q1 {
// Q3
public static void main(String[] args) {
InputReader in = new InputReader();
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
while (t-- > 0) {
int N = in.nextInt();
Hash... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | T = int(input())
while T!=0:
T-=1
n = int(input())
arr = [int(x) for x in input().split()]
st = set()
for i in range(1,2*n+1):
st.add(i)
for i in arr:
st.discard(i)
ans = []
for i in arr:
ans.append(i)
for j in sorted(st):
if j>i... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import atexit
import io
import sys
import math
from collections import defaultdict,Counter
# _INPUT_LINES = sys.stdin.read().splitlines()
# input = iter(_INPUT_LINES).__next__
# _OUTPUT_BUFFER = io.StringIO()
# sys.stdout = _OUTPUT_BUFFER
# @atexit.register
# def write():
# sys.__stdout__.write(_OUTPUT_BUFFER.get... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import java.util.Scanner;
public class C_623 {
@SuppressWarnings("resource")
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t = input.nextInt();
for (int test = 0; test < t; test++){
int n = input.nextInt();
int[] b = new int[n + 1];
boolean[] taken = new boolean... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | # Legends Always Come Up with Solution
# Author: Manvir Singh
import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict,deque,Counter
from bisect import *
from math import sqrt,pi,ceil
import math
from itertools import permutations
from copy import deepcopy
def main():
for t in range... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long double PI = acos(-1);
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
const int mod1 = 998244353;
const long long INF = 2e... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int t, n, b[105], a[205], vis[205], ret;
int main() {
int i;
scanf("%d", &t);
while (t--) {
memset(vis, 0, sizeof(vis));
ret = 0;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &b[i]);
vis[b[i]] = 1;
a[i * 2 - 1] = b[i];
... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
used = set(a)
ans = []
for i in range(n):
ans.append(a[i])
for j in range(a[i] + 1, n << 1 | 1):
if j not in used:
ans.append(j)
used.add(j)
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, k;
bool vis[510];
struct node {
int x, y;
} a[110];
int main() {
cin >> k;
while (k--) {
memset(vis, 0, sizeof(vis));
cin >> n;
int ma = 2 * n;
for (int i = 1; i <= n; i++) {
cin >> a[i].x;
vis[a[i].x] = true;
}
int now, t = ... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> b(n);
vector<int> ans;
map<int, bool> m;
for (int i = 0; i < n; i++) {
cin >> b[i];
m[b[i]] = 1;
}
int i;
for (i = 0; i < n; i++) {
ans.push_... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int cinn() {
int x;
scanf("%d", &x);
return x;
}
long long cinl() {
long long x;
scanf("%lld", &x);
return x;
}
void coutt(int x) { printf("%d ", x); }
vector<string> split(const string &s, char c) {
vector<string> v;
stringstream ss(s);
string x;
while ... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 |
"""
NTC here
"""
import sys
inp= sys.stdin.readline
input = lambda : inp().strip()
# flush= sys.stdout.flush
# import threading
# sys.setrecursionlimit(10**6)
# threading.stack_size(2**26)
def iin(): return int(input())
def lin(): return list(map(int, input().split()))
def main():
T = iin()
while T:
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | N = int(input())
for _ in range(N):
n = int(input())
b = list(map(int, input().split()))
a = [-1] * 2*n
pos = list(filter(lambda x: x not in b, range(1, 2*n + 1)))
f = True
for i, el in enumerate(b):
a[2*i] = el
st, end = 0, len(pos)
new_idx = (st + end) // 2
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | def main():
for _ in range(int(input())):
n = int(input())
a = list(map(int,input().split()))
t = 0
ans = []
used = [0] * (2 * n + 1)
for i in range(n):
used[a[i]] += 1
if used[a[i]] == 2:
t = 1
ans = -... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | def main(n, b):
#print("DEBUT")
tab = [0]*(2*n)
dispo = [True]*(2*n + 1)
for i in range(n):
tab[2*i] = b[i]
dispo[b[i]] = False
for i in range(n):
j = b[i]
test = True
while j <= (2*n) and test:
if not dispo[j]:
j += 1
else:
test = False
dispo[j] = False
tab[2*i + 1] = j
test = True
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | t=int(input())
for _ in range(t):
n=int(input())
b=list(map(int,input().split()))
a=[]
dic={}
for i in b:
dic[i]=1
for i in b:
a.append(i)
x=i+1
while(True):
if x in dic:
x+=1
else:
break
a.append(x)
dic[x]=1
f=True
for i in range(1,2*n+1):
if i in... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | for _ in range(int(input())):
n = int(input())
B = list(map(int, input().split()))
A = [0]*(2*n)
A[::2] = B
X = set(range(1, 2*n+1)) - set(B)
for i in range(n):
x = B[i] + 1
while x <= 2*n:
if x in X:
A[2*i+1] = x
X.remove(x)
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 |
def func():
n_case = int(input())
for i in range(n_case):
n = int(input())
b = list(map(int,input().split()))
res = {*(range(2*n+1))}-{*b}
a =[]
try:
for i in b :
minn = min(res - {*range(i)})
res-={minn}
a +=i,... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | n = int(input())
for i in range(n):
length = int(input())
b = [int(i) for i in input().split()]
c = list()
final = list()
pool = list()
var = False
for j in range(1, 2*length + 1):
if j not in b:
pool.append(j)
for j in range(len(b)):
var = False
fo... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | testCases = int(input())
for i1 in range(testCases):
length = int(input())
taken = [False]*length*2
b = list(map(int, input().split()))
a = [0]*2*length
for i2 in range(length):
taken[b[i2] - 1] = True
a[i2*2] = b[i2]
if taken.index(True) > 0:
print(-1)
else:
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | def solution(n: int, b: list):
ret = [0] * (2 * n)
for i in range(n):
ret[2*i] = b[i]
for j in range(b[i] + 1, 2 * n + 1):
if not (j in b):
ret[2 * i + 1] = j
b.append(j)
break
if (0 in ret):
print(-1)
return
els... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
using namespace std;
const long long MOD = 1e+9 + 7;
const long long INF = LLONG_MAX;
const int INFi = INT_MAX;
const long long N = 3e+5 + 8;
long long a[N], b[N];
long long check[N];
long lo... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io impor... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import java.io.*;
import java.util.*;
public class C {
public static void main(String[] args) {
FastReader scan = new FastReader();
PrintWriter out = new PrintWriter(System.out);
Task solver = new Task();
int t = scan.nextInt();
for(int tt = 1; tt <= t; tt++) solver.solve(t... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import sys
t = int(sys.stdin.readline())
for _ in range(t):
n = int(sys.stdin.readline())
sq = []
bq = [int(b) for b in sys.stdin.readline().split()]
aq = [True] * (2*n+1)
for b in bq:
aq[b] = False
for b in bq:
sq.append(b)
j = b+1
while j <= 2*n:
i... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
map<int, int> m1;
int a[101];
int b[101];
int main() {
int t, n, i, k, key;
scanf("%d", &t);
while (t--) {
m1.clear();
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &b[i]);
m1[b[i]] = 1;
}
key = 1;
for (i = 1; i <= n; i++)... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import java.util.*;
import java.io.*;
import java.math.*;
/**
*
* @Har_Har_Mahadev
*/
public class C {
private static long INF = 2000000000000000000L, M = 1000000007, MM = 998244353;
private static int N = 0;
public static int lower(ArrayList<Integer> q, int target) {
int ages[] = new int[q.size()];
int ii... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | t = int(input())
for j in range(t):
n = int(input())
values = [0]*(2*n+2)
b = list(map(int, input().split()))
a = [0]*(2*n+2)
#print(a,b)
for i in range(n):
a[2*i] = b[i]
values[b[i]] = 1
for i in range(n):
check = False
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long t, n, x[1005000];
void solve() {
cin >> n;
set<long long> s;
vector<pair<long long, long long> > b;
vector<pair<long long, pair<long long, long long> > > v;
for (int i = 1; i <= 2 * n; i++) s.insert(i);
for (int i = 1; i <= n; i++)
cin >> x[i], s.e... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | from typing import List
import collections
import bisect
import itertools
import functools
from fractions import gcd
import heapq
from math import ceil, sqrt, floor
# import sys
# sys.setrecursionlimit(50000)
def bisect_ceil(A, target):
low = 0
high = len(A) - 1
if not A or A[-1] < target:
return... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long t, n, b[100009], f[100009], j, fl;
struct st {
long long x, i;
} a[100009];
bool cmp(st a, st b) { return a.x < b.x; }
bool cm(st a, st b) { return a.i < b.i; }
int main() {
cin >> t;
while (t--) {
j = 1;
fl = 0;
cin >> n;
for (int i = 0; i <... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
check = [True] * (2 * n)
for i in range(n):
check[a[i]-1] = False
res = []
right = []
for idx, value in enumerate(a):
res.append(value)
i = value - 1
while i < 2*n and not check... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import java.util.*;
import java.awt.print.Book;
import java.io.*;
import java.math.BigInteger;
public class A {
static long mod = (long) (1e9 + 7);
public static long facn(long n, long x) {
long ans = 1;
for (int i = 1; i <= x; i++) {
ans *= n;
ans %= mod;
n--;
}
long k = 1;
long t = x;
for (in... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import sys
import math
get_string = lambda: sys.stdin.readline().strip()
get_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )
get_int = lambda: int(sys.stdin.readline())
#----------------------------------------------------------------------#
for _ in range(get_int()):
n=get_int()
b=get_li... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int arr[106];
int memo[206];
int solve(int n, int reff) {
for (int i = 1; i <= n; i++) {
if ((memo[i] == -1) && i > reff) {
memo[i] = 1;
return i;
}
}
return 0;
}
int main() {
int t;
cin >> t;
while (t--) {
int n, x;
memset(memo, -1, ... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | t = int(input())
for _ in range(t):
n = int(input())
seq = list(map(int, input().split()))
sol = [0]*(2*n)
nums = {i for i in range(1,2*n+1)}
for i in range(n):
sol[2*i] = seq[i]
nums.remove(seq[i])
geht = True
for i in range(n):
cand = [el for el in nums if el > sol[... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int test;
cin >> test;
while (test--) {
int n;
cin >> n;
int a[n + 5];
int v[2 * n + 10], u[2 * n + 10];
for (int i = 1; i <= 2 * n; i++) {
v[i] = i;
u[i] = i;
}
int j = 1;
for (int i = 1; i <= n; i++) {
c... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | kl = int(input())
for l in range(kl):
n = int(input())
t = n * 2
at = list(range(t + 1))
nl = [1] * t
b = []
rz = []
pr = 0
# print(nl)
# print(at)
for i in input().split():
i = int(i)
nl[i - 1] = 0
b = b + [i]
# print(nl)
# print(b)
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, a[209], vis[209], b[109];
set<int> s;
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
ios_base::sync_with_stdio(0);
int t;
cin >> t;
while (t--) {
cin >> n;
s.clear();
for (int i = 0; i < n * 2; i++) s.insert(i + 1);
for (... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | for _ in range(int(input())):
n=int(input())
b=[int(x) for x in input().split()]
a=[]
for i in range(n):
a.append(b[i])
k=b[i]
while(k in a or k in b):
k+=1
if(k>2*n):
print(-1)
break
a.append(k)
else:
print(*a) | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | /*
/$$$$$ /$$$$$$ /$$ /$$ /$$$$$$
|__ $$ /$$__ $$| $$ | $$ /$$__ $$
| $$| $$ \ $$| $$ | $$| $$ \ $$ ... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | I=input
for _ in[0]*int(I()):
n=2*int(I());a=[];b=*map(int,I().split()),;c={*range(n+1)}-{*b};i=1
try:
for x in b:y=min(c-{*range(x)});c-={y};a+=x,y;i+=2
except:a=-1,
print(*a) | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t-- > 0) {
int n;
cin >> n;
int ar[n];
unordered_map<int, int> umap;
for (int i = 0; i < n; i++) {
cin >> ar[i];
umap[ar[i]] = 1;
}
int ans[2 * n];
int k = 0;
int flag1 = 0;
for (... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | t=int(input())
for i in range(t):
n=int(input())
ans=[]
l=[int(i) for i in input().split()]
unl=[]
for i in range(1,2*n+1):
if i not in l:
unl.append(i)
#print(l,unl)
ok=True
for i in range(2*n):
if i%2==0:
ans.append(l[i//2])
else:
... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
signed main() {
long long nn;
cin >> nn;
while (nn--) {
long long n;
cin >> n;
vector<long long> vec(n + 1);
vector<long long> res(2 * n + 1);
vector<long long> vissited(2 * n + 1, 0);
for (long long i = 1; i <= n; ++... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | from math import *
from collections import *
t = int(input())
for y in range(t):
n = int(input())
a = list(map(int,input().split()))
ch = [0 for i in range(2*n+1)]
b = [-1 for i in range(2*n)]
for i in range(n):
ch[a[i]] = 1
b[2*i] = a[i]
flag = 0
for i in range(0,2*n,2):
m = -1
for j in range(b[i],2*n+1... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int power(long long int a, long long int c) {
if (c == 0) return 1;
if (c % 2 == 0) {
long long int m = power(a, c / 2);
return (m * m) % mod;
}
return (a * power(a, c - 1)) % mod;
}
int main() {
ios_base::sync_wit... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
public class Two {
public static void main(String[] args) {
... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | '''
@sksshivam007 - Template 1.0
'''
import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())... | PYTHON3 |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | #include <bits/stdc++.h>
template <typename T>
std::istream& operator>>(std::istream& input, std::vector<T>& v) {
for (T& a : v) input >> a;
return input;
}
void no_answer() { std::cout << -1 << '\n'; }
void answer(const std::vector<unsigned>& v) {
const char* separator = "";
for (const unsigned x : v) {
st... | CPP |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 |
import java.util.Arrays;
import java.util.Scanner;
public class C_623 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int q = in.nextInt();
for(int tc=0;tc<q;tc++){
int n=in.nextInt();
int[] b = new int[n];
int[] a = new in... | JAVA |
1315_C. Restoring Permutation | You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contains the number of test cases t (1 β€ t β€ 100).
The first line of... | 2 | 9 | I=input
for _ in[0]*int(I()):
n=2*int(I());a=[0]*n;b=a[::2]=*map(int,I().split()),;c={*range(n+1)}-{*b};i=1
try:
for x in b:y=a[i]=min(c-{*range(x)});c-={y};i+=2
except:a=-1,
print(*a) | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.