output stringlengths 52 181k | instruction stringlengths 296 182k |
|---|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n;
cin >> n;
set<int> used;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0 && !used.count(i)) {
used.insert(i);
n /= i;
break;
}
}
for (int i = 2; i * ... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test ca... |
#include <bits/stdc++.h>
using namespace std;
void gao(int n) {
for (int i = 2; i * i < n; i++) {
if (n % i == 0) {
for (int j = i + 1; j * j < n / i; j++) {
if (n / i % j == 0) {
cout << "YES" << endl;
cout << i << ' ' << j << ' ' << n / i / j << endl;
return;
... | ### Prompt
Please provide a cpp coded solution to the problem described below:
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent tes... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, i, cnt = 0, d, ar[3];
cin >> n;
for (i = 2; i * i <= n; i++)
if (n % i == 0) {
ar[cnt++] = i;
n /= i;
if (cnt == 2) break;
}
if (cnt == 2) {
ar[2] = n;
sort(ar, ar + 3);
if (ar[0] != ar[1] && ar[1] != ar[2]... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test ca... |
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200001];
long long int vist[200001], maxx;
void dfs(long long int node) {
vist[node] = 1;
maxx = max(maxx, node);
for (long long int child : adj[node])
if (!vist[child]) dfs(child);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL)... | ### Prompt
Please create a solution in cpp to the following problem:
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void printDivisors(long long n, set<long long> &s, vector<long long> &v) {
for (long long i = 2; i <= sqrt(n); i++) {
if (n % i == 0) {
if (n / i == i) {
s.insert(i);
v.push_back(i);
} else {
s.insert(... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent tes... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n;
int num[maxn], cnt;
int seq[maxn];
bool Find(int res, int now) {
for (int i = 1; i <= now; i++) {
if (seq[i] == res) return true;
}
return false;
}
void Init();
int main() {
int T;
scanf("%d", &T);
while (T--) Init();
return 0... | ### Prompt
Create a solution in CPP for the following problem:
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Input
... |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> v;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
v.push_back(i);
if (v.size() == 2) {
v.push_back(n / i);
break;
}
n /= i;
}
}
v.erase(unique(v.begin(), v.end()), ... | ### Prompt
Please create a solution in cpp to the following problem:
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long i, j, k, n;
cin >> n;
map<long long, long long> mp;
long long x = n;
while (x % 2 == 0) {
mp[2]++;
x /= 2;
}
for (i = 3; i * i <= x; i += 2) {
while (x % i == 0) {
... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
Inp... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> f, c;
int r = n;
int co{0};
while (r % 2 == 0) {
r = r / 2;
co++;
}
if (co > 0) {
f.push_back(2);
... | ### Prompt
Please create a solution in Cpp to the following problem:
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
... |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int MAXN = (int)1e5 + 5;
const int MOD = (int)1e9 + 7;
const int INF = 0x3f3f3f3f;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
bool mul(int n, int& a, int& b, int& c) {
a = INF, b = INF, c = INF;
for (int i = 2; i * i *... | ### Prompt
Develop a solution in CPP to the problem described below:
You are given one integer number n. Find three distinct integers a, b, c such that 2 β€ a, b, c and a β
b β
c = n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
... |
#include <bits/stdc++.h>
using namespace std;
void err() { cout << endl; }
template <class T, class... Ts>
void err(const T& arg, const Ts&... args) {
cout << arg << ' ';
err(args...);
}
using ll = long long;
using db = double;
using pII = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#include <bits/stdc++.h>
using namespace std;
long long int modPow(long long int x, long long int n, long long int mod) {
long long int r = 1;
x = x % mod;
while (n) {
if (n & 1) r = (r * x) % mod;
n = n >> 1;
x = (x * x) % mod;
}
return r;
}
int main() {
long long int t, i, j, k, l, n, m, a, b,... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int T, n, tot;
int a[N], b[N << 1];
bool vis[N << 1];
int main() {
scanf("%d", &T);
while (T--) {
memset(vis, false, sizeof(vis));
scanf("%d", &n);
for (register int i = 1; i <= n; ++i) scanf("%d", &a[i]), vis[a[i]] = true;
bool jay = ... | ### Prompt
Please create a solution in Cpp to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")
using namespace std;
const double... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(2 * n + 1), b(n + 1), c(2 * n + 1, 0);
set<int> d;
for (int i = 1; i <= n; i++) {
cin >> b[i];
c[b[i]] = 1;
}
... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line c... |
#include <bits/stdc++.h>
using namespace std;
int arr[1005];
int counter[1005];
int main() {
int tc;
cin >> tc;
while (tc--) {
memset(arr, 0, 1005);
memset(counter, 0, 1005);
int flag = 0;
vector<int> v;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
counter[... | ### Prompt
Your task is to create a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
cin >> t;
int vis[205], p = 0;
memset(vis, 0, sizeof(vis));
while (t--) {
++p;
int n, b[205];
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> b[i]... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#include <bits/stdc++.h>
using namespace std;
int t, n;
int main() {
cin >> t;
while (t--) {
int f = 0;
cin >> n;
vector<int> a;
a.push_back(0);
map<int, int> m;
int b[2 * n + 5];
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
if (x >= 2 * n) f = 1;
a.push_back(x... | ### Prompt
Please provide a cpp coded solution to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5 + 1;
void setIO(string name) {
ios_base::sync_with_stdio(0);
cin.tie(0);
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
int main() {
in... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = -1e-2;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const long long mod = 1e9 + 7;
const int Mx = INT_MAX;
const int Mn = INT_MIN;
const long long MX = LLONG_MAX;
const long long... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
template <class T>
bool ckmin(T& a, const T& b) {
return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epo... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
set<int> prime;
void SieveOfEratosthenes(int n) {
bool prme[n + 1];
memset(prme, true, sizeof(prme));
for (int p = 2; p * p <= n; p++) {
if (prme[p] == true) {
for (int i = p * p; i <= n; i += p) prme[i] = false;
}
}
for (int p = 2; p <= n; p++)
... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#include <bits/stdc++.h>
using namespace std;
int mpow(int base, int exp);
void solve() {
long long int n;
cin >> n;
vector<long long int> v(n);
vector<long long int> cnt(2 * n + 1, 0);
for (long long int i = 0; i < (n); i++) {
cin >> v[i];
cnt[v[i]]++;
}
vector<long long int> out;
for (long lon... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
int main() {
int i, j, k, t, n, l, largest_element;
scanf("%d", &t);
int result[t][200];
int largest_element_array[t];
for (i = 0; i < t; i++) {
int count = 0;
scanf("%d", &n);
largest_element = 2 * n;
largest_element_array[i] = largest_element;
int array_given[n];... | ### Prompt
Please create a solution in cpp to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
int f(map<int, int> &mp, int b[], int n, int l) {
bool x = 0;
for (int j = l + 1; j <= 2 * n; j++) {
if (!mp[j]) {
mp[j] = 1;
x = 1;
return j;
}
}
return 0;
}
int main() {
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
in... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line c... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, p = 0;
cin >> n;
int a[210], b[105], maxm = 0;
for (int i = 1; i <= n; i++) cin >> b[i];
bool g[210];
memset(g, false, sizeof(g));
for (int i = 1; i <= 2 * n; i += 2) a[i] = b[(i + 1) / 2],... | ### Prompt
Please create a solution in cpp to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int INF = 1e18;
void solve() {
long long int n;
cin >> n;
long long int a[n], b[2 * n];
for (long long int i = 0; i < n; i++) cin >> a[i];
set<long long int> s;
for (long long int i = 1; i < 2 * n + 1; i++) s.in... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line c... |
#include <bits/stdc++.h>
using namespace std;
vector<int> solve(int N, const vector<int>& B) {
vector<int> pos(2 * N + 1, -1);
for (int i = 0, _n = (N); i < _n; ++i) {
int x = B[i];
pos[x] = i;
}
set<int> missing;
for (int n = (1), _b = (2 * N); n <= _b; ++n) {
if (pos[n] < 0) missing.insert(n);
... | ### Prompt
Construct a CPP code solution to the problem outlined:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line c... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
istream::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int q;
cin >> q;
for (; q > 0; q--) {
int n;
cin >> n;
int b[n];
bool mk[n + n + 10];
for (int i = 0; i <= n + n; i++) mk[i] = 0;
for (int ... | ### Prompt
In CPP, your task is to solve the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line con... |
#include <bits/stdc++.h>
using namespace std;
long long INF = 1 << 28;
const double pi = acos(-1.0);
int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};
int dir[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};
int knight[8][2] = {1, 2, 1, -2, 2, 1, 2, -1, -1, 2, -1, -2, -2, 1, -2, -1};
const long double EPS = 1e-7;
long long gcd(lo... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long power(long long a, long long b, long long m = mod) {
long long x = 1;
while (b) {
if (b & 1) {
x = 1ll * x * a % m;
}
a = 1ll * a * a % m;
b /= 2;
}
return x;
}
const int N = 1e5 + 9;
signed main() {
i... | ### Prompt
Create a solution in Cpp for the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line cont... |
#include <bits/stdc++.h>
const long long MX = 1e18, N = 1e4 + 10;
const double PI = 3.141592653589793238;
using namespace std;
long long n, m, ans[N], a[N], t;
map<int, int> mp;
int main() {
cin >> t;
while (t--) {
cin >> n;
bool yes = true;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
++mp[a... | ### Prompt
Please create a solution in cpp to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e2 + 10;
bool mark[maxn];
int ans[maxn];
int main() {
ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
bool flag = true;
memset(mark, false, sizeof(mark));
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a... | ### Prompt
Please provide a cpp coded solution to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
int Search(vector<long long int> v1, long long int x1) {
long long int j;
for (j = 0; j < v1.size(); j++) {
if (x1 == v1[j]) {
return j;
} else {
continue;
}
}
return -1;
}
int Search2(long long int v[], long long int x, long long int n) {
... | ### Prompt
Generate a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contai... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int b, c = 0, sum = 0, i = 0, s, j, n, d = 0, q = 0, e, f, t = 0, x,
h, l = 0, k = 0, x1, x2, y1, y2, m;
cin >> t;
vector<long long int> v;
vector<long long int> a;
vector<long long int> z;
map<long long int, long long i... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
const long long dx[8] = {-1, 0, 1, 0, -1, 1, 1, -1},
dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long long kdx[8] = {-2, -1, 1, 2, 2, 1, -1, -2},
kdy[8] = {1, 2, 2, 1, -1, -2, -2, -1};... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line c... |
#include <bits/stdc++.h>
using namespace std;
bool compare(string &s1, string &s2) { return s1.size() < s2.size(); }
string lower(string second) {
transform(second.begin(), second.end(), second.begin(), ::tolower);
return second;
}
string upper(string second) {
transform(second.begin(), second.end(), second.begin... | ### Prompt
Create a solution in CPP for the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line cont... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t;
cin >> t;
while (t--) {
long long vis[205] = {0};
long long n, c = 0;
cin >> n;
long long a[n];
vector<long long> b;
for (long long i = 0; i < n; i++) {
cin >>... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#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... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
int t, n, b[105], a[205], vis[205], ret;
int main() {
int i;
scanf("%d", &t);
while (t--) {
memset(vis, 0, sizeof(vis));
ret = 0;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &b[i]);
vis[b[i]] = 1;
a[i * 2 - 1] = b[i];
... | ### Prompt
Please formulate a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
int n, k;
bool vis[510];
struct node {
int x, y;
} a[110];
int main() {
cin >> k;
while (k--) {
memset(vis, 0, sizeof(vis));
cin >> n;
int ma = 2 * n;
for (int i = 1; i <= n; i++) {
cin >> a[i].x;
vis[a[i].x] = true;
}
int now, t = ... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line c... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> b(n);
vector<int> ans;
map<int, bool> m;
for (int i = 0; i < n; i++) {
cin >> b[i];
m[b[i]] = 1;
}
int i;
for (i = 0; i < n; i++) {
ans.push_... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#include <bits/stdc++.h>
using namespace std;
int cinn() {
int x;
scanf("%d", &x);
return x;
}
long long cinl() {
long long x;
scanf("%lld", &x);
return x;
}
void coutt(int x) { printf("%d ", x); }
vector<string> split(const string &s, char c) {
vector<string> v;
stringstream ss(s);
string x;
while ... | ### Prompt
Generate a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contai... |
#include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
using namespace std;
const long long MOD = 1e+9 + 7;
const long long INF = LLONG_MAX;
const int INFi = INT_MAX;
const long long N = 3e+5 + 8;
long long a[N], b[N];
long long check[N];
long lo... | ### Prompt
Generate a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contai... |
#include <bits/stdc++.h>
using namespace std;
map<int, int> m1;
int a[101];
int b[101];
int main() {
int t, n, i, k, key;
scanf("%d", &t);
while (t--) {
m1.clear();
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &b[i]);
m1[b[i]] = 1;
}
key = 1;
for (i = 1; i <= n; i++)... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#include <bits/stdc++.h>
using namespace std;
long long t, n, x[1005000];
void solve() {
cin >> n;
set<long long> s;
vector<pair<long long, long long> > b;
vector<pair<long long, pair<long long, long long> > > v;
for (int i = 1; i <= 2 * n; i++) s.insert(i);
for (int i = 1; i <= n; i++)
cin >> x[i], s.e... | ### Prompt
Your task is to create a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#include <bits/stdc++.h>
using namespace std;
long long t, n, b[100009], f[100009], j, fl;
struct st {
long long x, i;
} a[100009];
bool cmp(st a, st b) { return a.x < b.x; }
bool cm(st a, st b) { return a.i < b.i; }
int main() {
cin >> t;
while (t--) {
j = 1;
fl = 0;
cin >> n;
for (int i = 0; i <... | ### Prompt
Generate a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contai... |
#include <bits/stdc++.h>
using namespace std;
int arr[106];
int memo[206];
int solve(int n, int reff) {
for (int i = 1; i <= n; i++) {
if ((memo[i] == -1) && i > reff) {
memo[i] = 1;
return i;
}
}
return 0;
}
int main() {
int t;
cin >> t;
while (t--) {
int n, x;
memset(memo, -1, ... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int test;
cin >> test;
while (test--) {
int n;
cin >> n;
int a[n + 5];
int v[2 * n + 10], u[2 * n + 10];
for (int i = 1; i <= 2 * n; i++) {
v[i] = i;
u[i] = i;
}
int j = 1;
for (int i = 1; i <= n; i++) {
c... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#include <bits/stdc++.h>
using namespace std;
int n, a[209], vis[209], b[109];
set<int> s;
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
ios_base::sync_with_stdio(0);
int t;
cin >> t;
while (t--) {
cin >> n;
s.clear();
for (int i = 0; i < n * 2; i++) s.insert(i + 1);
for (... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t-- > 0) {
int n;
cin >> n;
int ar[n];
unordered_map<int, int> umap;
for (int i = 0; i < n; i++) {
cin >> ar[i];
umap[ar[i]] = 1;
}
int ans[2 * n];
int k = 0;
int flag1 = 0;
for (... | ### Prompt
Develop a solution in Cpp to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
signed main() {
long long nn;
cin >> nn;
while (nn--) {
long long n;
cin >> n;
vector<long long> vec(n + 1);
vector<long long> res(2 * n + 1);
vector<long long> vissited(2 * n + 1, 0);
for (long long i = 1; i <= n; ++... | ### Prompt
Please create a solution in CPP to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int power(long long int a, long long int c) {
if (c == 0) return 1;
if (c % 2 == 0) {
long long int m = power(a, c / 2);
return (m * m) % mod;
}
return (a * power(a, c - 1)) % mod;
}
int main() {
ios_base::sync_wit... | ### Prompt
In cpp, your task is to solve the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line con... |
#include <bits/stdc++.h>
template <typename T>
std::istream& operator>>(std::istream& input, std::vector<T>& v) {
for (T& a : v) input >> a;
return input;
}
void no_answer() { std::cout << -1 << '\n'; }
void answer(const std::vector<unsigned>& v) {
const char* separator = "";
for (const unsigned x : v) {
st... | ### Prompt
Please create a solution in CPP to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#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) ... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line c... |
#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--)... | ### Prompt
Create a solution in Cpp for the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line cont... |
#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... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#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... | ### Prompt
Generate a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contai... |
#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... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#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,... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#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)
... | ### Prompt
Construct a CPP code solution to the problem outlined:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line c... |
#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... | ### Prompt
In Cpp, your task is to solve the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line con... |
#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];... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#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... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line c... |
#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... | ### Prompt
Generate a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contai... |
#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;
}... | ### Prompt
Please create a solution in cpp to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#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;
... | ### Prompt
Please formulate a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#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);
... | ### Prompt
Generate a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contai... |
#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);
... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#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++) {
... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#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 ... | ### Prompt
Please create a solution in Cpp to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#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 <... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line c... |
#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;
... | ### Prompt
Please formulate a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#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... | ### Prompt
Develop a solution in CPP to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#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] = {... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#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 = ... | ### Prompt
Please create a solution in cpp to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#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... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#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... | ### Prompt
Please create a solution in Cpp to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#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;... | ### Prompt
Generate a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contai... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
int done = 1;
for (int i = 0; i < t; i++) {
done = 1;
int n;
cin >> n;
int A[n];
int B[2 * n];
int check[2 * n];
for (int i = 0; i < 2 * n; i++) {
check[i] = 0;
}
for (int j = 0; j < n; j++) {
... | ### Prompt
Please create a solution in cpp to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &V) {
os << "[ ";
for (auto v : V) os << v << " ";
return os << "]";
}
template <class T>
ostream &operator<<(ostream &os, const set<T> &S) {
os << "{ ";
for (auto s : S) os << s << " ";
return ... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> b(n);
vector<int> a(2 * n);
vector<char> used(2 * n);
for (int i = 0; i < n; ++i) {
cin >> b[i... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
vector<bool> flag(2 * n + 1, false);
for (int i = 0; i < n; i++) {
cin >> a[i];
flag[a[i]] = true;
}
vector<int> st;
for (int i = 1; i <= 2 * n; i++) {
... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 9;
const int MOD = 1000000007;
int mod = 999998639;
inline long long qpow(long long b, long long e, long long m = MOD) {
long long a = 1;
for (; e; e >>= 1, b = b * b % m)
if (e & 1) a = a * b % m;
return a;
}
set<int> s;
int b[109];
vector<... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using second = set<T>;
template <typename T>
using v = vector<T>;
const int Max = 2e5 + 100;
const int Mx = 5e1 + 10;
const int Len = 1e6;
const int MOD = 1e9 + 7;
const long long INF = 1e18;
int A[Max];
bool usedNum[Max];
int main() {
int q;
cin >... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e16;
const long long N = 1e5 + 1;
const long long mod = 1e9 + 7;
void solve() {
long long n;
cin >> n;
long long b[n + 1];
for (long long i = 1; i <= n; i++) {
cin >> b[i];
}
deque<long long> ans(2 * n + 1), rem;
for (long long i = 1... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int b[n + 1];
set<int> s;
for (int i = 0; i < n; i++) {
cin >> b[i];
s.insert(b[i]);
}
int a[n * 2 + 5];
memset(a, 0, sizeof(a));
int pos = 0;
for (int i =... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line c... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 0x3f3f3f3f;
const long long nax = 0;
void solve() {
long long n;
vector<long long> b(210, 0), arr(105);
vector<bool> vis(210, 0);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> arr[i];
vis[arr[i]] = 1;
... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int a[205], b[105];
set<int> st;
int n;
void solve() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> b[i];
st.clear();
for (int i = 1; i <= 2 * n; i++) st.insert(i);
for (int i = 1; i <= n; i++) {
st.erase(b[i]);
}
if (st.size()... | ### Prompt
Please provide a cpp coded solution to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
for (pair<T1, T2> &t : v) is >> t.first >> t.second;
return is;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
for (T &t : v) is >> t;
return is... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
vector<int> a(n), ans(2 * n), used(2 * n + 5);
for (int i = 0; i < n; i++) {
cin >> a[i];
used[a[i]] = 1;
... | ### Prompt
Please create a solution in cpp to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long int, long long int> a,
pair<long long int, long long int> b) {
return a.first < b.first;
}
bool check(int a) {
int sum = 0;
while (a > 0) {
sum += (a % 10);
a /= 10;
}
if (sum == 10) return true;
return false;
}
bool prim... | ### Prompt
Please provide a CPP coded solution to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t, n, last;
cin >> t;
bool can;
for (int u = 0; u < t; ++u) {
cin >> n;
vector<int> a(2 * n + 1, 0);
vector<int> c(2 * n + 1, 0);
last = 1;
vector<pair<int, int>> b(n);... | ### Prompt
Construct a CPP code solution to the problem outlined:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line c... |
#include <bits/stdc++.h>
using namespace std;
const long int full = 205;
int n;
int b[full], a[full];
bool f[full];
int find(int s) {
int x = 0;
for (int i = s + 1; i <= 2 * n; i++)
if (f[i] == false) {
f[i] = true;
x = i;
break;
}
return x;
}
void process() {
for (int i = 1; i <= 2 * ... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
double tick() {
static clock_t oldtick;
clock_t newtick = clock();
double diff = 1.0 * (newtick - oldtick) / CLOCKS_PER_SEC;
oldtick = newtick;
return diff;
}
long long gcd(long long a, long long b) {
if ((a == 0) || (b == 0)) {
return a + b;
}
return gc... | ### Prompt
Please formulate a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(n), b(2 * n);
for (int &i : a) cin >> i;
set<int> s;
for (int i = 1; i <= 2 * n; i++) s.insert(i);
for (i... | ### Prompt
Your task is to create a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
#include <bits/stdc++.h>
using namespace std;
const int siz = 1e5 + 7;
const int siz2 = 2e5 + 7;
int t, n;
int a[222];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> t;
A:
while (t--) {
cin >> n;
map<int, int> mp;
vector<int> Ans;
for (int i = 0; i < n; ++i) {
... | ### Prompt
Please formulate a CPP solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first lin... |
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const double pie = 3.14159265358979323846;
const char nl = '\n';
const char spc = ' ';
template <typename Type>
istream &operator>>(istream &in, vector<Type> &v) {
long long int n = v.size();
for (int i = 0; i < n; i++) in >> v[i];
r... | ### Prompt
Generate a Cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The first line contai... |
#include <bits/stdc++.h>
using namespace std;
inline long long read() {
char c = getchar();
long long f = 1, x = 0;
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 1) + (x << 3) + (c ^ '0');
c = getchar();
}
return x * f;
}
long ... | ### Prompt
Please provide a cpp coded solution to the problem described below:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<bool> a(2 * n + 1);
vector<int> res(2 * n);
bool good = true;
for (int i = 0; i < n; i++) {
int k;
cin >> k;
if (a[k] == false) {
a[k] = true;
... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a sequence b_1, b_2, β¦, b_n. Find the lexicographically minimal permutation a_1, a_2, β¦, a_{2n} such that b_i = min(a_{2i-1}, a_{2i}), or determine that it is impossible.
Input
Each test contains one or more test cases. The fir... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.