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... | # N, M, P = map(int, input().split())
# A = list(map(int, input().split()))
T = int(input())
for t in range(T):
N = int(input())
B = list(map(int, input().split()))
S = set(B)
out = []
for n in range(2*N):
if n%2 == 0:
out.append(str(B[n//2]))
else:
curr = B[(n-1)//2]
fl = 0
for i in range(1, (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... | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
Un... |
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 = 1e9 + 7;
const long long INF = 1e18;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
if (a < b) {
a = 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 int MAX = 5e5 + 10;
int b[105], a[205], n;
int main() {
int t;
cin >> t;
while (t--) {
cin >> n;
for (int i = 1; i <= n; i++) cin >> b[i];
map<int, int> mp;
set<int> s;
for (int i = 1, j = 1; i <= 2 * n; i += 2, j++) {
a[i] = b[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())
elt=[]
for i in range(t):
n=int(input())
l=[]
c=[]
chaine=input()
el=chaine.split(" ")
for e in el:
l.append(int(e))
c.append(int(e))
elt.append((n,c,l))
for n,c,l in elt:
for k in range(2*n):
m=0
if k+1 not in l:
g=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... | #include <bits/stdc++.h>
using namespace std;
int b[100];
int a[201];
int main(void) {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
set<int> left;
for (int i = 1; i <= (2 * n); i++) {
left.insert(i);
}
for (int i = 0; i < n; i++) {
cin >> b[i];
left.erase(b[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())
b = list(map(int, input().split()))
flag = True
s = set(b)
ans = []
for i in range(n):
ans.append(b[i])
k = b[i]
while(k in s):
k += 1
if k > n*2:
flag = False
br... |
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.math.*;
public class HelloWorld {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
while(t-- > 0) {
int n = scanner.nextInt();
int[] arr = new int[n];
boolean[] 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>
#pragma GCC optimize("Ofast")
using namespace std;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
template <class T>
inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T>
inline bool chmin(T &a, T b) {
if (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... | testcases=int(input())
masterlist=[]
for i in range(testcases):
input()
tempseq=list(map(int,input().split(" ")))
masterlist.append(tuple(tempseq))
def lexicographer(tup):
buildlist=[]
for i in range(len(tup)):
val=tup[i]
buildlist.append(val)
run=True
... |
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 {
/**
*
* k = 1
*
* 2^17+1 2^17 0
* 1 2^17+1 1
*
* dp[2][2] = max(
*/
public static void main(String[] args) {
FastReader sc = new FastReader();
int t = sc.nextInt();
outer: whi... |
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
def fastio():
from io import StringIO
from atexit import register
global input
sys.stdin = StringIO(sys.stdin.read())
input = lambda : sys.stdin.readline().rstrip('\r\n')
sys.stdout = StringIO()
register(lambda : sys.__stdout__.write(sys.stdout.getvalue(... |
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;
long long b[n];
unordered_map<long long, long long> mapp;
for (long long i = 0; i < n; i++) {
cin >> b[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());A=list(map(int,input().split()));mark=[];C=[]
for i in A:
m=i+1
while True :
if m in A or m in C:
m+=1
else:
break
mark.append(i);mark.append(m);C.append(m)
Ans=[];jaya=mark.copy(... |
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.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
import java.util.Queue;
import java.ut... |
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
def main():
for t in range(int(input())):
n = int(input())
s = [i for i in range(1,2*n+1)]
l = [int(j) for j in input().split()]
for i in range(n):
s.remove(l[i])
z = list(zip(l, [i for i in range(n)]))
# z.sort()
s.sort()
ans = [0]*(2*n)
# print(z, s)
... |
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 dif(long long int a, long long int b) {
return ((a / b) + (a % b != 0));
}
vector<long long int> v;
long long int c[100100], par[100100];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long int t;
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() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int b[n + 1];
int i, j;
for (int i = 1; i <= n; i++) cin >> b[i];
int a[2 * n + 1];
bool vis[2 * n + 1];
for (int i = 0; i <= 2 * n; i++) vis[i] = false;
for (int i = 1; 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 java.io.*;
import java.util.*;
public class Permutation {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
for (int i1 = 0; i1 < t; i1 ++){
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... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author ky112233
*/
public class Main {
public static void main(String[] args) {
InputStream ... |
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.Math.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
public class A {
public static void main(String[] args) throws NumberFormatException, IOException {
// TODO Auto-generated method stub
BufferedReader br ... |
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 Code2802 {
public static void main(String args[]){
Reader s = new Reader();
int t = s.nextInt();
// 4 1 3
Outer:
while(t-- > 0){
int n = s.nextInt();
int a[]= new int[2*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... | for _ in range(int(input())):
n = int(input())
b = [int(i) for i in input().split()]
missed = []
sorted_b = sorted(b)
for ind, num in enumerate(sorted_b):
if ind != 0:
missed.extend(list(range(sorted_b[ind - 1] + 1, num)))
else:
missed.extend(list(range(1, 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... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
public class Solution
{
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader(
... |
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... | I = input
for _ in range(int(I())):
try:
n = int(I())
b = list(map(int, I().split(' ')))
a = [0 for i in range((2 * n) + 1)]
s = []
for i in range(n):
if a[b[i]] == 0:
a[b[i]] = 1
s.append(str(b[i]))
s.append('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... | from sys import stdin,stderr
def rl():
return [int(w) for w in stdin.readline().split()]
def solve(n, b):
f = [True for i in range(2*n+1)]
for x in b:
if not f[x]:
return [-1]
f[x] = False
a = []
for x in b:
a.append(x)
for y in range(x+1, 2*n+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... | I=input
exec(int(I())*'I();b=*map(int,I().split()),;s={*range(2*len(b)+1)}-{*b};a=[]\ntry:\n for x in b:a+=x,min(s-{*range(x)});s-={*a}\nexcept:a=-1,\nprint(*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;
void solve(int n, int b[]) {
set<int> s;
int a[2 * n];
for (int i = 0; i < (int)2 * n; i++) {
s.insert(i + 1);
}
for (int i = 0; i < (int)n; i++) {
s.erase(b[i]);
}
if (*min_element(s.begin(), s.end()) == 1 ||
*max_element(b, b + n) == 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;
long long t, i, a[100000], h, b[10000], k[10000], g, p, r, l, n;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> t;
while (t--) {
cin >> n;
for (i = 1; i <= n; i++) {
cin >> a[i];
b[a[i]]++;
}
i = 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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
set<int> s;
for (int i = 1; i <= 2 * n; i++) s.insert(i);
vector<int> b(2 * n);
bool er = false;
for (int i = 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
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
from collections import *
ORDA = 97 # a
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return [int(i) for i in input().split()]
def lcm(a, b): return abs(a * 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... | import java.io.*;
import java.util.*;
import java.lang.*;
public class c1 {
public static FScanner scan;
public static PrintWriter out;
public static void main(String[] args) {
scan=new FScanner();
out=new PrintWriter(new BufferedOutputStream(System.out));
// int t=1;
int 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... | import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;
public class RestoringPermutation {
public static void main(String[] args) {
FastScanner I = new FastScanner(); //Input
OutPut O = new OutPut(); //Output
int T = I.nextInt();
while (T-->0) {
int N = I.nextInt();
boolean[] 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... | for tc in range(int(input())):
n = int(input())
b = list(map(int, input().split(' ')))
b.insert(0, 0)
a = (2*n+1)*[0]
s = set()
flag = True
for i in range(1,n+1):
a[2*i-1] = b[i]
if b[i] in s:
flag = False
break
s.add(b[i])
for i in range(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 Solution{
long rem = 1000000007L;
public Solution(){
Scanner sc = new Scanner(System.in);
int tests = sc.nextInt();
for(int t=1; t<=tests; t++){
int n = sc.nextInt();
int[] b = new int[n];
boolean[] found = new boolean[(2*n)+1];
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 math
import atexit
import io
import sys
# input = sys.stdin.readline
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER
@atexit.register
def write():
sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
def array_to_string(a):
s = ""
for i in a:
s += str(i)
return s
t = int(inp... |
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 t, n, a[1005], dd[2005], kt, b[2005], m;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> t;
while (t--) {
memset(dd, 0, sizeof(dd));
memset(b, 0, sizeof(b));
m = 0;
cin >> n;
for (long long i = 1; 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() {
ios::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
int t = 1;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n], b[2 * n];
unordered_map<int, int> m;
int flag = 0;
for (long long int i = 0; i < n; i++) {
cin >> 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... | t = int(input())
while(t):
t=t-1
n = int(input())
b = [int(s) for s in input().split()]
dic = [0]*((2*n)+1)
for i in b:
dic[i] = 1
x = (2*n)+1
a = []
ans = 1
# print(dic)
for i in b:
flag = 0
# print(i)
for j in range(i+1,x):
if di... |
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 sys import stdin
from collections import defaultdict
import bisect
input=stdin.readline
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split()))
dict=defaultdict(int)
arr=[]
for i in range(n):
arr.append([a[i],i])
dict[a[i]]=1
arr.sort()
#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 Input():
tem = input().split()
ans = []
for it in tem:
ans.append(int(it))
return ans
from collections import Counter
T = Input()[0]
def solve(n, b):
m = 2*n
a = []
for i in range(n):
a.append([b[i],i])
a.sort(reverse=True)
vis=[0 for i in range(m+1)]
ans=[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=int(input())
while t:
n=int(input())
b=input().split()
visited=[0 for i in range(2*n+1)]
a=[]
for i in range(n):
b[i]=int(b[i])
visited[b[i]]=1
for i in range(n):
a.append(b[i])
flag=False
for j in range(b[i]+1,2*n+1):
if(visited[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... | for _ in range(int(input())):
n = int(input())
se = set()
flag = True
li = list(map(int, input().split()))
for ele in li:
se.add(ele)
newli = []
for ele in li:
newli.append(ele)
srch = ele + 1
if srch>2*n:
flag = False
break
while Tru... |
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 helper(helpArr,num):
for i in range(num,len(helpArr)):
if helpArr[i]==0:
return i+1
return -1
def soln(n,arr):
helpArr=[0]*(2*n)
for i in arr:
helpArr[i-1]=1
ans=[]
for i in arr:
temp=helper(helpArr,i)
if temp==-1:
return -1
hel... |
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())
arr=list(map(int,input().split()))
ans=[0]*(n*2)
for i in range(n):
ele=arr[i]
ans[2*i]=ele
included=set(arr)
i=1
broken=0
while i<(2*n):
starting=ans[i-1]
ending=(2*n)
for j in range(starting+1,ending+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;
signed main() {
long long tt;
cin >> tt;
while (tt--) {
long long n;
cin >> n;
vector<long long> a(2 * n), b(n);
set<long long> help;
for (long long i = 0; i < n; ++i) {
cin >> b[i];
help.insert(2 * i);
help.insert(2 * i + 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... | t=int(input())
while t:
t-=1
n=int(input())
b=list(map(int, input().split()))
cpy=b[::]
s=list(set(range(1, 2*n+1)) - set(b))
s.sort()
cpy.sort()
d=dict()
for val, k in enumerate(cpy):
d[k]=val
ans=[]
flag=True
for i in b:
val=0
for j in s:
if i<j:
val=j
s.remove(j)
break
if val:
... |
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,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... |
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())
ans = [0] * ((2 * n))
list2 = [True] * (2 * n + 1)
b = list(map(int, input().split()))
fin = True
for k,j in enumerate(b):
ans[2*k] = j
list2[j] = False
for l,j in enumerate(b):
for k in range(j+1, 2 * n +1):
if list2[k] == True:
list2[k] = 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... | t = int(input())
while t:
t -= 1
n = int(input())
b = [int(i) for i in input().split()]
a = []
if (not 1 in b) or 2*n in b:
print("-1")
else:
disp = []
for i in range(1,2*n+1):
if not i in b:
disp.append([i, True])
for i in b:
min = -1
a.append(i)
for j in disp:
if j[1] and j[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::sync_with_stdio(false);
cin.tie(0);
long long int n;
int t;
cin >> t;
while (t--) {
cin >> n;
vector<long long int> v(n), vv;
for (long long int i = 0; i <= n - 1; i++) cin >> v[i];
bool arr[210];
memset(arr, 0, sizeof(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... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T gcd(T a, T b) {
while (b != 0) swap(b, a %= b);
return a;
}
template <typename T>
inline void seethis(vector<T> vect) {
for (T x : vect) cout << x << " ";
cout << "\n";
}
void err(istream_iterator<string> it) {}
template <typename T, 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... |
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
public static void process()throws IOException
{
int n=ni(),arr[]=new int[n+1];
HashSet<Integer> t_set = new HashSet<Integer>();
for(int i=1;i<=n;i++){
t_set.add(arr[i]=ni());
}... |
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;
inline int read() {
int ans = 0, sign = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') sign = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
ans = ans * 10 + (ch - '0');
ch = getchar();
}
return ans * sign;
}
cons... |
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 = lambda: sys.stdin.readline().rstrip()
def last_proverka(v):
for i in range(len(v)):
i += 1
if i not in v:
return -1
return True
# v - ans
# h - b
def l_proverka(v, c):
for i in range(len(c)):
if v[i] == c[i]:
return False
return ... |
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()))
A=[]
for i in range(n):
A.append(B[i])
for j in range(B[i]+1,1000):
if(j not in A and j not in B):
A.append(j)
break
C=[]
for i in range(0,2*n):
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... | for i in range(int(input())):
n=int(input())
nums=[int(i) for i in input().split()]
check=set(nums)
s=max(nums)
l=[int(i)+1 if int(i)+1 not in check else 0 for i in range(2*n)]
l=sorted(list(set(l)))
l.remove(0)
o=""
b=0
for i in nums:
s=0
while s<len(l) and l[s]<... |
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.swing.*;
import java.awt.desktop.SystemSleepEvent;
import java.util.*;
import java.io.*;
public class Main {
public static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedRead... |
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 sys
from io import BytesIO, IOBase
# region fastio
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
self.write = self.buffer.wr... |
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 sys import stdin
from collections import defaultdict
from bisect import bisect_right
input=stdin.readline
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split()))
dict=defaultdict(int)
arr=[]
for i in range(n):
arr.append([a[i],i])
dict[a[i]]=1
arr.s... |
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.*;
public class Main
{
static long mod=1000000007l;
static int max=Integer.MAX_VALUE,min=Integer.MIN_VALUE;
static long maxl=Long.MAX_VALUE,minl=Long.MIN_VALUE;
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
sta... |
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;
cin >> n;
int b[n];
unordered_set<int> s;
for (int i = 0; i < n; i++) {
cin >> b[i];
s.insert(b[i]);
}
int a[2 * n], k = 0;
for (int i = 0; i < 2 * n; i++) {
if (i % 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... | //189301019.akshay
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.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 sys
# sys.stdin=open("input1.in","r")
# sys.stdout=open("outpul.out","w")
for _ in range(int(input())):
N=int(input())
L=list(map(int,input().split()))
Hash=[0]*(2*N+1)
for i in range(N):
Hash[L[i]]+=1
Nahi=[]
for i in range(N):
FLAG=0
for j in range(L[i]+1,2*N+1):
if Hash[j]==0:
FLAG=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;
long long a[250];
long long b[250];
long long c[250];
signed main() {
long long t;
cin >> t;
while (t--) {
long long f;
cin >> f;
memset(b, 0, sizeof(b));
for (long long i = 1; i <= f; i++) {
cin >> a[i];
b[a[i]] = 1;
}
long long cn... |
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 ans[N];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
;
long long t = 1;
cin >> t;
while (t--) {
long long 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... | import java.util.*;
import java.io.*;
public class B{
public static void main(String[] args)
{
FastScanner fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int t = fs.nextInt();
m:for(int tt=0;tt<t;tt++)
{
int n = fs.nextInt();
Set<Integer> s = new HashSet();
int[] arr = new ... |
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 = lambda: sys.stdin.readline().rstrip()
from bisect import bisect_left as bl, bisect_right as br
for _ in range(int(input())):
n=int(input())
a=[int(i) for i in input().split()]
b=[0]*(n*2)
for i in range(0,2*n,2):
b[i]=a[i//2]
st=set([i for i in range(1,2*n+1)])
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... |
t = int(input())
for _ in range(t):
n = int(input())
b = [int(x) for x in input().split()]
d = sorted(b)
c = []
j = 0
for i in range(1, 2 * n + 1):
if j < len(d) and i == d[j]:
j += 1
else:
c.append(i)
j = 0
out = []
for val in b:
ou... |
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;
vector<int> v1;
vector<int> v2;
set<int> s;
for (int k = 0; k < t; ++k) {
int n;
bool f = true;
cin >> n;
v2.resize(2 * n);
for (int i = 0; i < 2 * n; ++i) {
s.insert(i + 1);
}
for (int i = 0; i < 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 MAX = 200005;
int a[MAX];
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
bool flag = false;
int maxc = n * 2;
bool b[205];
memset(b, false, sizeof(b));
for (int i = 0; i < n; i++) {
cin >> a[i];
b[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... | def read():
n = int(input())
b = list(map(int, input().split()))
return n, b
def solve(n, b):
a = [0] * 2 * n
marked = [False] * 2 * n
for bi in b:
marked[bi - 1] = True
for i in range(n):
a[2 * i] = b[i]
try:
next_unmarked = marked.index(False, b[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;
void solve() {
int n;
cin >> n;
vector<int> a(2 * n);
set<int> s;
for (int i = int(1); i < int(2 * n + 1); ++i) {
s.insert(i);
}
for (int i = 0; i < int(n); ++i) {
cin >> a[2 * i];
s.erase(a[2 * i]);
}
for (int i = 0; i < int(n); ++i) {
set... |
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 n, m;
long long int arr[3000000];
long long int brr[3000000];
long long int an[3000000];
array<long long int, 2> dp[3000000];
string st;
vector<long long int> vec;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
long long in... |
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.lang.reflect.Array;
import java.util.*;
import java.awt.Point;
public class Main {
static int mod=(int)1e9+7;
public static void main(String[] args) throws Exception {
FastReader sc = new FastReader();
StringBuilder sb=new StringBuilder();
int t=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... | '''
5
1
1
2
4 1
3
4 1 3
4
2 3 4 5
5
1 5 7 2 8
'''
class NotFoundError(Exception):
def __str__(self):
return "Lexicograohic sequence nnot found"
def returnNumber(bFinal, a, index):
for i in range(len(a)):
# print(a[i], bFinal[index])
if a[i] > bFinal[index] and a[i] not in bFinal:
... |
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.print.DocFlavor;
import javax.swing.text.html.HTMLDocument;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Inet4Address;
import java.nio.charset.IllegalCharsetNameException;
import java.sql.SQLOutput;
import java.util... |
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;
cin >> n;
int a[n + 1];
int b[2 * n + 1];
int temp[2 * n + 1];
for (int i = 1; i <= 2 * n; i++) temp[i] = 0;
bool con1 = false, con2 = false;
for (int i = 1; i <= n; i++) {
cin >>... |
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 M = 1000000007;
int main() {
ios_base::sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> v;
map<int, int> m;
int z = 0;
int j;
int b[n];
for (long long i = (0); i < (n); i++) {
cin >> ... |
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())
x = list(map(int, input().split(" ")))
b = [0]
for i in x:
b.append(i)
vis = [False for cnt_used in range(2*n + 1)]
a = [0 for cnt_a in range(2*n + 1)]
set_elem_b = True
for i in range(1, n+1):
num = int(b[i])
if 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())
b=list(map(int,input().split()))
if 2*n in b:
print(-1)
continue
arr=[0 for i in range(2*n)]
for i in b:
arr[i-1]=1
res=[]
for i in b:
res.append(i)
k=i
while k<2*n:
if arr[k]==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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class C1315 {
public static void main(String[] args) {
FastScanner fs=new FastScanner();
int T=fs.nextInt();
for (int tt=1; tt<=T; tt++) {
int n=fs.nextInt();
int firstN... |
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 M = 220;
int a[M], v[M];
int t, n;
int main() {
scanf("%d", &t);
while (t--) {
int cd;
memset(v, 0, sizeof(v));
scanf("%d", &n);
for (int i = 1; i <= 2 * n; i += 2) {
scanf("%d", &a[i]);
v[a[i]] = 1;
}
int num = 0;
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... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
void solve() {
int n, m, i, j, k, l, r, x, y, z, a, b, c;
cin >> n;
vector<int> v(n);
for (int zz = 0; zz < n; zz++) cin >> v[zz];
bool chk[n * 2 + 5];
memset(chk, 0, sizeof(chk));
for (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... | import java.io.*;
import java.util.*;
public class Restoring_Permutation
{
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
for (int i = 1; i <= T; 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 java.util.*;
public class Problem1315c {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int[] getLine = new int[n];
int[] numLine = new int[210];
... |
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 *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = int(1.5e6)
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
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... | # from future import print_function,division
# range = xrange
import sys
input = sys.stdin.readline
from bisect import bisect_right
# sys.setrecursionlimit(10**9)
from sys import stdin, stdout
def main():
for _ in range(int(input())):
n = int(input())
l = [int(s) for s in input().split()]
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... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
b = list(map(int, input().split()))
a = [0] * (2 * n)
used = [False] * (2 * n + 1)
for i in range(2 * n):
if i % 2 == 0:
a[i] = b[i // 2]
used[a[i]] = True
poss = True
... |
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
t, = map(int, input().split())
for _ in range(t):
N = int(input())
B = list(map(int, input().split()))
vs = set(B)
cc = 0
for i in range(2*N, 0, -1):
# print(i)
if i in vs:
cc -= 1
else:
cc += 1
if cc < 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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int b[n];
set<int> s;
for (int i = 0; i < n; i++) {
cin >> b[i];
s.insert(b[i]);
}
bool sad = false;
vector<int> a;
for (int i = 0; i < n; i++) {
a.push_... |
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 = 100 + 3;
int a[N], b[N], vis[300];
int main() {
int t, n, x;
map<int, int> mp;
cin >> t;
while (t--) {
cin >> n;
int jg = 0, bj = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
b[i * 2 - 1] = a[i];
vis[a[i]]++;
if (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;
const int N = 2e2 + 10;
const long long mod = 1e9 + 7;
const long long inf = 1e18 + 10;
long long a[N], b[N], c[N], use[N];
set<int> st[N];
void solve() {
long long n;
cin >> n;
fill(c, c + N, 0);
fill(use, use + N, 0);
for (int i = 1; i <= n; i++) {
cin >> 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... | # restoring_permutation1.py
from collections import defaultdict
for _ in range(int(input())):
n = int(input())
b = list(map(int,input().split()))
mydick = dict()
mydick = defaultdict(lambda:0,mydick)
for i in range(n):
mydick[b[i]]=1
p = 2*n
a = []
# a.append(b[0])
ok = True
... |
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... | n=int(input())
for i in range(n):
a_l=int(input())
l=list(map(int,input().split()))
temp=[0]*((max(l)*2)+1)
dicti={}
flag=False
for j in range(a_l):
if(l[j]>=a_l*2):
flag=True
break
if((1 not in l) or flag==True):
print(-1)
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... |
for _ in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
ans=[]
a=0
for i in range(n):
ans.append(l[i])
c=l[i]
while(c in l or c in ans):
c+=1
if c>2*n:
a=-1
break
ans.append(c)
if a==-1:
pr... |
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(0,t):
n=int(input())
b=[]
c=[]
a=list(map(int,input().split()))
k1=1
k2=n*2
if(k1 in a and k2 not in a):
for j in range(1,2*n+1):
if(j not in a):
b.append(j)
for j in range(0,n):
k=a[j]+1
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... |
import java.io.*;
import java.util.*;
/**
* A simple template for competitive programming problems.
*/
public class Solution {
//final InputReader in = new InputReader("input.txt");
final InputReader in = new InputReader(System.in);
final PrintWriter out = new PrintWriter(System.out);
final int mo... |
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 = 2e2 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9,
inf = 1e18 + 7;
const long long infll = 1e18 + 7;
long long n, m, k;
long long ans, cnt, tmp, idx, mx = -inf, mn = inf;
long long x, y, z;
string s, t;
long long a[N], b[N], c[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... | import java.io.*;
import java.util.*;
public class Codeforces {
public static void main(String[] args) throws IOException {
FastScanner fs = new FastScanner();
PrintWriter pw = new PrintWriter(System.out);
int t = fs.getInt();
while (t-- > 0) {
int n = fs.getInt();
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.