#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
int ile = 0;
void rozw(vector<int> A, vector<int> B, bool c) {
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 ;
}
if (szA == 2 && szB == 2) {
int pol = 1;
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]);
}
rep(i, 1) {
int now = Query(B[i]);
if (c) {
if (now == ile) {
B2.pb(B[i]);
B1.pb(B[i + 1]);
}
else {
B1.pb(B[i]);
B2.pb(B[i + 1]);
}
}
else {
if (now == ile) {
B1.pb(B[i]);
B2.pb(B[i + 1]);
}
else {
B2.pb(B[i]);
B1.pb(B[i + 1]);
}
}
}
bool c2 = c ^ 1;
rozw(A1, B1, c2);
rozw(A2, B2, c);
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]);
}
rep(i, szB) {
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;
}
bool c2 = c ^ 1;
rozw(A1, B1, c2);
rozw(A2, B2, c);
}
void Solve(int N) {
vector<int> A;
vector<int> B;
for (int v = 1; v <= 2 * N; v++) {
int now = Query(v);
if (now == ile) {
B.pb(v);
}
else {
A.pb(v);
}
ile = now;
}
// 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... |