This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
int last = 0;
bool ask(int x) {
int nw = Query(x);
bool g = (last != nw);
last = nw;
return g;
}
void solve(vector<int> a, vector<int> b, bool f) {
if (a.size() == 1) {
Answer(a[0], b[0]);
return;
}
int n = a.size();
int mid = n / 2;
vector<int> la, lb, ra, rb;
for (int i = 0; i < n; i++) {
if (i < mid) ask(b[i]), lb.push_back(b[i]);
else rb.push_back(b[i]);
}
for (int i : a) {
// if (la.size() == mid) ra.push_back(i);
// else if (ra.size() == n - mid) la.push_back(i);
if (f) {
if (ask(i)) ra.push_back(i);
else la.push_back(i);
} else {
if (ask(i)) la.push_back(i);
else ra.push_back(i);
}
}
solve(la, lb, f ^ 1);
solve(ra, rb, f);
}
void Solve(int N) {
vector<int> a, b;
for (int i = 1; i <= 2 * N; i++) {
if (ask(i)) a.push_back(i);
else b.push_back(i);
}
solve(a, b, 0);
}
# | 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... |