description stringlengths 35 9.39k | solution stringlengths 7 465k |
|---|---|
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... | #include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int nag = 2e5 + 5;
template <typename T>
void add(T& a, T b) {
a += b;
while (a >= mod) a -= mod;
while (a < 0) a += mod;
}
template <typename T>
void mul(T& a, T b) {
a = a * b % mod;
}
template <typename T>
void up_self(T& a, T b) ... |
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... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = 1000000000;
const long long N = 2 * (1e2) + 5;
long long ar[N];
long long ar2[N];
long long ar3[N];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
;
long long t = 1;
cin >> t;
while (t--)... |
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0), ios::sync_with_stdio(false);
int t, n;
cin >> t;
while (t--) {
cin >> n;
vector<int> a(n), b(2 * n);
vector<bool> used(2 * n + 1, false);
for (int i = 0; i < n; ++i) {
cin >> a[i];
used[a[i]] = true;
}
boo... |
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... | import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class ProblemC {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int tt = 0; tt < t; tt++) {
int n = sc.nextInt();
int[] input = n... |
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... | # from collections import defaultdict
for _ in range(int(input())):
n = int(input())
b = list(map(int, input().split()))
a = []
taken = [False] * (2*n+1)
for bi in b: taken[bi] = True
for bi in b:
a.append(bi)
next = bi+1
while next <= 2*n and taken[next]:
next += 1
if next <= 2*n:
a.append(next... |
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... | t = int(input())
b_all = list()
for i in range(t):
n = int(input())
b_str = input().split(' ')
b_all.append([int(r) for r in b_str])
results = list()
for b in b_all:
n = len(b)
used = [False] * (2*n+1)
in_res = [False] * (2*n+1)
bad_seq = False
for num in b:
if num > 2*n:
... |
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... | #include <bits/stdc++.h>
using namespace std;
const int mod = 998244353.;
const int N = 1e6 + 5;
bool sortbysec(const pair<pair<long long, long long>, long long> &a,
const pair<pair<long long, long long>, long long> &b) {
return (a.second > b.second);
}
long long powermod(long long x, long long y, long... |
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... | import sys
queries = int(sys.stdin.readline())
for query in range(queries):
length = int(sys.stdin.readline())
arr = [int(x) for x in sys.stdin.readline().strip().split()]
mx = arr[0]
ans_arr = [0] * (length*2)
arr_ins = [x for x in range(length*2,0,-1)]
for el in arr:
del arr_ins[arr_... |
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... | t=int(input())
for i in range(t):
op=[]
n=int(input())
x=list(input().split())
xi=[int(i) for i in x]
for j in range(2*n):
if j%2==0:
t=xi[j//2]
op.append(t)
else:
op.append(0)
xx=1
for j in range(n):
z=op[xx-1]+1
if z in op... |
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long n, i, p = 0, q, h, r = 0, j;
cin >> n;
long long a[n], b[2 * n], c[2 * n];
memset(c, 0, sizeof(c));
for (i = 0; i < n; i++) {
cin >> a[i];
}
for (i = 0; i < n; i++) {
c... |
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... | #include <bits/stdc++.h>
using namespace std;
const int N = 410;
int b[N];
int a[N];
int t, n;
bool used[N];
int find(int x) {
for (int i = x + 1; i <= 2 * n; i++) {
if (!used[i]) {
return i;
}
}
return -1;
}
int main() {
ios::sync_with_stdio(false);
cin >> t;
while (t--) {
memset(used, 0,... |
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... | import sys
input = sys.stdin.readline
for j in range(int(input())):
n = int(input())
b = list(map(int, input().split(" ")))
save = b.copy()
temp = set(b)
c =[]
for k in range(1, 2*n+1):
if k not in temp:
c.append(k)
b.sort()
c.sort()
ansDict = {}
ans = 0
f... |
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... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class test {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t=Int... |
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... | import java.io.OutputStream;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedHashSet;
import java.io.Writer;
import java.io.OutputStreamWriter;
... |
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... |
#!/usr/bin/env python
from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
import datetime
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def main():
starttime=datetime.da... |
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... | for _ in range(int(input())):
n = int(input())
ar1 = list(map(int, input().split()))
ar2 = []
kek = set()
for i in range(1, 2 * n + 1):
if i not in ar1:
kek.add(i)
ans = []
flag = 0
for i in range(n):
ans.append(ar1[i])
num = 2 * n + 1
for num ... |
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... | a=int(input())
for i in range(a):
n=int(input())
z=list(map(int,input().split()))
t=[0 for i in range(3*max(z))]
ans=[]
for i in range(len(z)):
if(t[z[i]]==0):
t[z[i]]=1
for i in range(len(z)):
ans.append(z[i])
for j in range(z[i]+1,len(t)):
if(t[j... |
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... | import os
import heapq
import sys,threading
import math as mt
import operator
from copy import copy
from collections import defaultdict,deque
from io import BytesIO, IOBase
sys.setrecursionlimit(2*10 ** 5)
#threading.stack_size(2**27)
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a %... |
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... | import java.util.*;
import java.io.*;
public class C623
{
public static void main(String [] args)
{
MyScanner sc = new MyScanner();
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
int t = sc.nextInt();
while (t > 0) {
int n = sc.nextInt();
... |
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... | #include <bits/stdc++.h>
using namespace std;
long long int fun(vector<long long int> &v, long long int t, long long int l,
long long int r) {
if (l == r) return l;
if (abs(l - r) == 1) {
long long int t1 = abs(5 * v[l] - 2 * t);
long long int t2 = abs(5 * v[r] * 2 * t);
if (t1 < t2)
... |
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... | # ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode... |
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... | for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
arr2 = []
for i in arr:
arr2.append(i)
t = i+1
while t in arr or t in arr2:
t += 1
arr2.append(t)
if max(arr2) == 2 * n:
print(*arr2)
else:
print("-1")... |
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... | from bisect import bisect_right
for _ in range(int(input())):
n = int(input())
b = list(map(int, input().split()))
try:
a = [0] * 2 * n
a[::2] = b.copy()
m = sorted(set(range(1, 2 * n + 1)).difference(set(b))) + [float('inf')]
for i in range(1, 2 * n, 2):
a[i]... |
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... | #!/usr/bin/env python
def gen(b):
a = list(range(1, 2 * n + 1))
a = [x for x in a if x not in b]
seq = []
for b_ in b:
try:
idx = next(x for x, v in enumerate(a) if v > b_)
seq += [b_, a[idx]]
del a[idx]
except:
return None
return seq
... |
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... | # ΠΠΎΠ΄ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π½Π°ΠΏΠΈΡΠ°Π» Π½Π° ΡΠ·ΡΠΊΠ΅ Python 3
import sys
import bisect
def main():
n = int(sys.stdin.readline())
q = [int(i) for i in sys.stdin.readline().split()]
w = []
for i in range(1, 2 * n + 1):
if i not in q:
w.append(i)
w.sort()
res = [0 for i in range(2*n)]
for i i... |
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... | """
// Author : snape_here - Susanta Mukherjee
"""
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def ii(): return int(input(... |
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... | for _ in range(int(input())):
n = int(input())
s = [*map(int,input().split())]
ans = []
for i in s:
ans.append(i)
t = i+1
while t in s or t in ans:
t += 1
ans.append(t)
if sorted(ans) == [i for i in range(1,2*n + 1)]:
print(*ans)
else:
... |
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... | #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
import threading
from collections import Counter
mod=998244353
def main():
for _ in range(int(input())):
n=int(input())
arr=list(map(int,input().split()))
a=list(zip(arr,range(1,n+1)))
# a.sort()
a.r... |
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... | #Pye
from os import path
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
maxn = 200005
dd = [0 for i in range(maxn)]
a = [0 for i in range(maxn)]
if path.exists('inp.txt'):
stdin = open("inp.txt", "r")
q = int(stdin.readline())
for _ in range(q):
s = []; check = 0;
n = int(stdin.r... |
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... | import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.lang.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class Contest {
//static ArrayList<Integer> prime=new ArrayList();
public static TreeMap<Long,Integer> t1=new TreeM... |
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... | import java.util.*;
public class C {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for (int r = 0; r < t; r++) {
int n = in.nextInt();
int[] b = new int[n];
int[] a = new int[2 * n];
TreeSe... |
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... | import java.io.*;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import java.util.Scanner;
import static java.lang.Math.*;
public class C {
private static class Pair<K, V> {
K k;
V v;
public Pair(K k, V v) {
this.k = k;
this.v = v;
... |
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... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
used = [0 for i in range(2*n+1)]
flg = 1
for i in range(n):
if b[i] > i*2+1:
print(-1)
flg = 0
break
used[b[i]] = 1
if flg == 0:
continue
ans = []
for i in range(n):
... |
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... | t=int(input())
for _ in range(t):
n=int(input())
l=list(map(int,input().split()))
r=[]
for i in range(1,2*n+1):
if i in l:
pass
else:
r.append(i)
i=0
k=[]
while len(r)>0 or i<n:
for j in range(len(r)):
if l[i]<r[j]:... |
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... | for namber in range(int(input())):
tmp = input()
data = list(map(int, input().split()))
sortdat = sorted(data)
if sortdat[0] == 1:
maxlen = 2
for i in range(1, len(data)):
if sortdat[i] - sortdat[i - 1] > maxlen:
print(-1)
break
eli... |
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... | import java.util.*;
import static java.lang.System.*;
public class Main
{
public static void main(String[] args) {
Scanner s = new Scanner(in);
int t = s.nextInt();
s.nextLine();
while (t-- > 0) {
int n = s.nextInt();
int[] a = new int[n];
boole... |
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... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int b[100 + 5], a[200 + 10];
bool used[200 + 10];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t, n;
cin >> t;
while (t--) {
cin >> n;
memset(a, -1, sizeof a);
memset(used, false, sizeof used);
memset(b, -1, si... |
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... |
import javafx.util.Pair;
import org.omg.CORBA.INTERNAL;
import sun.awt.image.ImageWatched;
import sun.reflect.generics.tree.Tree;
import java.nio.channels.ScatteringByteChannel;
import java.text.SimpleDateFormat;
import java.util.*;
public class Main {
public static void main(String[] args) {
... |
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... | t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int,input().split()))
d = {i:0 for i in range(1,n*2+1)}
for i in arr:
d[i] = 1
resultset = []
gflag = True
for i in arr:
flag = False
# print(i,d)
for j in range(i+1,n*2+1):
if d[j] == 0:
resultset.append(i)
resultset.append(j... |
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... | for _ in range(int(input())):
n = int(input())
b = [int(__) for __ in input().split()]
shit = list(range(1, 2 * n + 1))
ans = []
flag = 1
for i in b:
shit.remove(i)
for i in b:
for j in shit:
if j > i:
ans.append(i)
ans.append(j)
... |
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... | import java.util.Scanner;
public class Perms {
public static void main(String[] args) {
Scanner scanner= new Scanner(System.in);
int tCount= scanner.nextInt();
int [][]cases= new int[tCount][];
for(int i=0; i<tCount;i++){
int itemsCount= scanner.nextInt();
int[]arr= new int[itemsCount];
for(int j=0;... |
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... | t=input()
from collections import Counter,defaultdict
for i in range(t):
n=input()
l=list(map(int,raw_input().split()))
l1=[]
c=Counter(l)
d=defaultdict(int)
ans=True
for j in l:
for k in range(j+1,201):
if c[k]<>1 and d[k]<>1:
l1.append(j)
... |
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... | t = int(input())
for _ in range(t):
n = int(input())
b = list(map(int, input().split()))
if max(b) >= n*2 or 1 not in b:
print(-1)
else:
a = [0]*(2*n)
ok = True
for i in range(n):
a[i*2] = b[i]
while 0 in a:
moved = False... |
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... | import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.TreeSet;
public class Main {
private static final String NO = "NO";
private static ... |
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... | t = int(input())
for _ in range(t):
n = int(input())
b = list(map(int, input().split()))
a = [0] * 1111
for c in b:
a[c] = 1
res = []
for x in b:
flag = False
for j in range(x+1, 2*n+1):
if a[j] == 0:
flag = True
a[j] = 2
... |
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... | t = int(input())
for _ in range(t):
n = int(input())
b = list(map(int, input().split()))
c = [0]*(2*n)
d = []
for i in range(0, 2*n, 2):
c[i] = b[i//2]
for j in range(1, (2*n)+1):
if (j not in c):
d.append(j)
for i in range(n):
for j in r... |
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... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;
/**
* Built using CHelpe... |
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... | if __name__ == '__main__':
for _ in range (int(input())):
n = int(input())
l = list(map(int, input().split()))
a = min(l)
b = max(l)
if a != 1 or b == 2*n:
print(-1)
else:
B = []
d = dict()
for i in range (n):
d.setdefault(l[i],1)
for i in range (1,(2*n)+1):
d.setdefault(i,0)
if ... |
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... | /**
* ******* Created on 23/2/20 10:07 PM*******
*/
import java.io.*;
import java.util.*;
public class C1315 implements Runnable {
private static final int MAX = (int) (1E5 + 5);
private static final int MOD = (int) (1E9 + 7);
private static final long Inf = (long) (1E14 + 10);
private void solve... |
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... | for _ in range(int(input())):
n = int(input())
b = list(map(int, input().split()))
ans = []
for i in b:
ans.append(i)
t = i+1
while(t in b) or (t in ans):
t += 1
ans.append(t)
if(max(ans) == 2*n):
print(*ans)
else:
print("-1") |
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... | import sys
import collections
input = sys.stdin.readline
def main():
t = int(input())
for _ in range(t):
N = int(input())
B = [int(x) for x in input().split()]
c = collections.Counter()
ans = []
for b in B:
if c[b] > 0:
print(-1)
... |
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... | import java.util.*;
import java.io.*;
public class Main{
static int repow(int b,int p){
long a = b;
long res=1;
while(p>0){
if(p%2==1){
res*=a;
}
a*=a;
p/=2;
}
return (int)res;
}
static int repow(int b,int p,int modder){
long a = b%modder;
long res=1;
... |
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... | #include <bits/stdc++.h>
using namespace std;
int n;
int num[110];
int ans[220];
bool used[220];
void init() {
for (int i = 0; i <= 105; i++) {
num[i] = 0;
ans[i * 2] = ans[2 * i + 1] = 0;
used[i * 2] = used[2 * i + 1] = 0;
}
}
void solve() {
for (int i = 1; i <= n; i++) {
ans[2 * i - 1] = num[i];... |
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... | TC = int(input())
def get_unused(nums, res):
unused = set(range(1, 2 * n + 1))
for v in res:
unused.remove(v)
return unused
def solve(nums):
res = []
n = len(nums)
extra = 10 * n
used = [0] * (2 * n + 1)
for num in nums:
res.append(extra)
res.append(num)
... |
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... | t=int(input())
for _ in range(t):
n=int(input())
B=[int(i) for i in input().split()]
B_set=set(B)
check=True
Ans=[]
Used=[True]*(2*n)
for i in range(2*n):
if i+1 in B_set:
Used[i]=False
for b in B:
Ans.append(b)
for i in range(b,2*n):
if Used[i]:
Ans.append(i+1)
U... |
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... | import java.io.*;
import java.util.*;
import java.lang.Math;
public class Main{
static BufferedReader reader;
static StringTokenizer tokenizer;
static PrintWriter writer;
static int nextInt() throws IOException {
return Integer.parseInt(nextToken());
}
static long nextLong() throws IOException {
return Lon... |
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... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
using namespace std;
const int MX = 1e9 + 1;
const int Imp = -1;
const int N = 1e6 + 5;
const int M = 1e6 + 5;
const long long INF = 1e18 + 1;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout... |
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... | class GFG:
def __init__(self,graph, seq):
# residual graph
self.graph = graph
self.ppl = len(graph)
self.jobs = len(graph[0])
self.seq = seq
# A DFS based recursive function
# that returns true if a matching
# for vertex u is possible
d... |
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long b[n];
for (long long i = 0; i < n; i++) cin >> b[i];
bool c[2 * n + 1];
memset(c, true, 2 * n + 1);
long long a[2 * n];
memset(a, -1, 2 * n);
for (lo... |
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... | t=int(input())
for i in range(t):
n=int(input())
L=[int(j) for j in input().split()]
L1=[0]*(2*n)
L2=[]
for k in range(0,2*n,2):
L1[k]=L[k//2]
for l in range(1,(2*n)+1,1):
if(l not in L1):
L2.append(l)
for x in range(n):
for y in range(0,2*n,2):
... |
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... | #include <bits/stdc++.h>
using namespace std;
const long long N = 200 + 10;
const long long M = 1e5 + 10;
const long long inf = 1e9 + 7;
const long long Mod = 1e9 + 7;
const double eps = 1e-6;
int T;
int n;
int a[N], b[N];
bool fix[N];
bool f;
void init() {
for (int i = 0; i < N; ++i) {
fix[i] = 0;
}
f = 1;
}... |
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... | from collections import defaultdict
for _ in range(int(input())):
N = int(input())
List = [int(x) for x in input().split()]
Dict = defaultdict(int)
for i in List:
Dict[i] = 1
Res = []
flag = 0
for i in range(N):
Res.append(List[i])... |
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
bool used[314] = {};
int A[210] = {};
while (T--) {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> A[i * 2];
used[A[i * 2]] = true;
}
for (int i = 0; i < N; i++) {
int j = A[i * 2] + 1;
... |
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... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 200009;
const long long MOD = 119 << 23 | 1;
class {
public:
int a[222], b[222];
void solve() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
set<int> Se;
for (int i = 1; i <= 2 * n; ++i) {
Se.insert(i);
... |
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... | import sys
import math
import heapq
import collections
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write
def input():
return fast_reader().strip()
def print(*argv):
fast_writer(' '.join((str(i)) for i in argv))
fast_writer('\n')
def printspace(*argv):
fast_writer(' '.join((str(i)) for i in argv))
fas... |
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... | for _ in range(int(input())):
n=int(input())
b=list(map(int,input().split()))[:n]
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)
|
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... | def solve():
n = eval(input())
b = input().split()
vis = [0 for i in range(0, 420)]
a = [0 for i in range(0, 400)]
pos = 0
flag = True
for x in b:
vis[int(x)] = 1
for x in b:
y = int(x)
pos += 1
a[2 * pos - 1] = y
ok = False
for j in range(... |
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... | #include <bits/stdc++.h>
using namespace std;
const long long M = 1e8 + 7, maxn = 4e5 + 5;
long long int ans, n, m, x, y, q, k, a, b, sum;
int32_t main() {
cin >> q;
while (q--) {
cin >> n;
long long int a[n];
set<long long int> s;
k = 0;
for (long long int i = 1; i <= 2 * n; i++) s.insert(i);
... |
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, tmp;
cin >> n;
int a[2 * n];
bool ss[2 * n + 1];
for (int i = (0); i < (2 * n); i++) a[i] = -1;
for (int i = (0); i < (2 * n + 1); i++) ss[i] = false;
for (int i = (0); i < (n); i++) {
... |
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int t = 1;
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> t;
while (t--) {
long long int start = 0, end = 0, n, m, x = 0, y = 0, index = 0;
cin >> n;
long int arr[n];
unordered_map<long int, bool> mp;
for ... |
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... | for _ in range(int(input())):
n = int(input())
lst = [int(i) for i in input().split()]
s = {*(range(2 * n + 1))} - {*lst}
a = []
try:
for i in lst:
minn = min(s - {*range(i)})
s -= {minn}
a += i, minn
except:
a = -1,
print(*a)
|
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
int aa[n + 1], cc[n + 1], bb[n * 2 + 2], dd[2 * n + 2];
for (int i = 0; i < 2 * n + 2; i++) bb[i] = 1;
for (int i = 0; i <... |
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int inp[n];
set<int> s;
for (int i = 0; i < n; i++) {
cin >> inp[i];
s.insert(inp[i]);
}
vector<pair<int, int> > ans;
int act;
... |
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... | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void resPermu(int[] arr, int n){
HashSet<Integer> hset = new HashSet<Integ... |
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... | for _ in range(int(input())):
n = int(input())
dic = {x : 1 for x in range(1, 2*n+1)}
b = [];ans=True
for el in map(int, input().split()):
if el == 2*n:print(-1);ans = False
dic[el] = 0
b.append(el)
if ans:
if dic[1] == 1:print(-1);continue
a = {}
for ... |
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... | import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class C {
public void run() throws Exception {
FastScanner sc = new FastScanner();
int test = sc.nextInt();
outer:
for (int j = 0; j<test; j++) {
int n = sc.nextInt();
int[] b = new int[n];
int[] a = new int[2*n];... |
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... | for t in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(2*n)]
c=[False for i in range(2*n)]
i=0
j=0
while(i<2*n):
b[i]=a[j]-1
c[a[j]-1]=True
i+=2
j+=1
i,k,flag=1,0,1
while(i<2*n):
k=b[i-1]
flag=... |
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... | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 102;
int a[T], b[T];
int main() {
ios_base::sync_with_stdio(false);
int tc;
cin >> tc;
while (tc--) {
int n;
cin >> n;
vector<pair<int, int> > need;
set<int> disp;
for (int i... |
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... | for _ in range(int(input())):
n = int(input())
array = list(map(int, input().split()))
dick = {}
for i in array:
dick[i] = 1
ans = [0]*(2*n)
for i in range(n):
ans[2*i] = array[i]
flag = True
for i in range(n):
k = ans[2*i]
klag = False
for j in ra... |
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... | t = int(input())
for x in range(t):
n = int(input())
arr = list(map(int, input().split()))
count = 0
a = 0
out = []
fail = False
while(a < n):
out.append(arr[a])
count = out[-1]
while(count < 2*n):
count+=1
if (not count in arr) and (not count ... |
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... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 55;
int a[N];
pair<int, int> c[N];
int b[N];
bool vis[N];
int main() {
int t;
cin >> t;
while (t--) {
memset(vis, 0, sizeof vis);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
vis[a[i]] = 1;
c[i] = {... |
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... | t=int(input())
for i in range(t):
n=int(input())
l=[0]*2*n+[0,0]
b=list(map(int,input().split()))
if 1 not in b:print(-1)
else:
t=1
b.insert(0,0)
for i in range(1,n+1):
l[2*i-1],w=b[i],b[i]
while w in b or w in l:w+=1
if w>2*n:t=0;break
... |
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... | import javax.jws.soap.SOAPBinding;
import java.io.*;
import java.lang.reflect.Array;
import java.security.acl.LastOwnerException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.stream.Collectors;
public class Main {
static Long max = (lon... |
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... | t=int(input())
for i in range(t):
n=int(input())
arr=list(map(int,input().split()))
tot=[j for j in range(1,n*2+1)]
rem=[j for j in tot if j not in arr]
rem=sorted(rem)
liste=[]
for j in range(n):
b1=arr[j]
flag=False
for k in range(len(rem)):
if(rem[k... |
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... | #include <bits/stdc++.h>
using namespace std;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
pair<long long, long long> a[n];
long long re[2 * n + 1];
map<long long, long long> mp;
for (long long i = ... |
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... | t=int(input())
for _ in range(t):
n=int(input())
l=list(map(int,input().split()))
a=[*range(1,2*n+1)]
b=[i for i in a + l if i not in a or i not in l]
b.sort()
ans=[]
used=[]
f=0
for i in l:
for j in b:
if j>i and j not in used:
used.append(j)
... |
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... | #include <bits/stdc++.h>
using namespace std;
void solve() {
long long n;
cin >> n;
long long a[n + 10];
map<long long, long long> mp;
for (long long i = 0; i < n; i++) {
cin >> a[i];
mp[a[i]] = 1;
}
vector<long long> v;
for (long long i = 0; i < n; i++) {
v.push_back(a[i]);
for (long lo... |
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... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Vector;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStreamReader;
... |
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... | def min_largest(arr, x):
start = 0
end = len(arr) - 1
while start <= end:
mid = start + (end - start) // 2
if arr[mid] < x:
start = mid + 1
else:
end = mid - 1
result = start if start < len(arr) else -1
return result
def permutation(arr, n):
pres... |
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... | import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
/*
*
*/
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while(t-->0) {
int n = scan.nextInt();
int[] arr = new int[(2*n)];
boolean flag=false;
int[] nums = new int[2*n+1];
for(int... |
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... | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class MakingString implements Runnable
{
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
pri... |
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... | for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()));d={}
for i in range(n):
d[a[i]]=1
ans=[];f=0
for i in range(n):
if a[i]<2*n:
for j in range(a[i],(2*n)+2):
if not d.get(j) and j<=2*n:
ans.append(a[i])
... |
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... | nn = int(input())
for tt in range(nn):
total = []
num = int(input())
arr = []
arr1 = str(input())
arr1 = arr1.split()
dicts = {}
last = 2 * num
for i in arr1:
kt = int(i)
arr.append( int(i) )
dicts[kt] = 1
ans = []
flag = 0
for i in arr:
ans.... |
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... | #include <bits/stdc++.h>
using namespace std;
long long gcd(long long n, long long m) {
if (n == 0) return m;
return gcd(m % n, n);
}
bool ifprime(long long n) {
if (n == 1) return false;
long long i;
for (i = 2; i * i <= n; i++) {
if (n % i == 0) return false;
}
return true;
}
void disp(vector<long l... |
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... | import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args){
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
while (T != 0) {
... |
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... | import java.io.*;
import java.util.*;
public class GFG {
public static void main (String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(br.readLine().trim());
while(t--!=0){
int n=Integer.parseInt(br.readLine().trim());
Stri... |
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... | import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(ro... |
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... | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class RestoringPermutation1315C {
public static void main(String[] args) t... |
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... | for t in range(int(input())):
n = int(input())
l = [int(i) for i in input().split()]
visited = [0 for i in range(2 * n)]
res = []
for i in l:
visited[i - 1] = 1
for i in l:
temp = i
while (temp < 2 * n and visited[temp]):
temp += 1
if (temp >= 2 * n):
... |
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... | #include <bits/stdc++.h>
int b[100];
bool used[201];
int pair[201];
int main() {
int T;
scanf("%d", &T);
while (T--) {
std::fill(used, used + 201, false);
int n;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
int input;
scanf("%d", &input);
b[i] = input;
used[input] = true;... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.