#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define st first
#define nd second
#define pb push_back
random_device randek;
mt19937 rng(randek());
int ile = 0;
void rozw(vector<int> A, vector<int> B, bool c) {
shuffle(A.begin(), A.end(), rng);
shuffle(B.begin(), B.end(), rng);
int szA = A.size();
int szB = B.size();
// cout << szA << " " << szB << '\n';
if (szA == 0 && szB == 0) {
return ;
}
if (szA == 1 && szB == 1) {
Answer(A[0], B[0]);
return ;
}
int pol = szA/2;
vector<int> A1;
vector<int> A2;
vector<int> B1;
vector<int> B2;
rep(i, pol) {
ile = Query(A[i]);
A1.pb(A[i]);
}
for (int i = pol; i < szA; i++) {
A2.pb(A[i]);
}
bool all2 = false;
bool all1 = false;
rep(i, szB) {
if (all1) {
B1.pb(B[i]);
continue;
}
else if (all2) {
B2.pb(B[i]);
continue;
}
int now = Query(B[i]);
if (c) {
if (now == ile) {
B2.pb(B[i]);
}
else {
B1.pb(B[i]);
}
}
else {
if (now == ile) {
B1.pb(B[i]);
}
else {
B2.pb(B[i]);
}
}
ile = now;
if ((int)B1.size() == (int)A1.size()) {
all2 = true;
}
else if ((int)B2.size() == (int)A2.size()) {
all1 = true;
}
}
bool c2 = c ^ 1;
rozw(A1, B1, c2);
rozw(A2, B2, c);
}
void Solve(int N) {
vector<int> A;
vector<int> B;
bool allb = false;
for (int v = 1; v <= 2 * N; v++) {
if (allb) {
B.pb(v);
continue;
}
int now = Query(v);
if (now == ile) {
B.pb(v);
}
else {
A.pb(v);
}
ile = now;
if ((int)A.size() == N) {
allb = true;
}
}
// rep(i, N) {
// cout << A[i] << " ";
// }
// cout << '\n';
// rep(i, N) {
// cout << B[i] << " ";
// }
// cout << '\n';
rozw(A, B, true);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |