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;
using vi = vector<int>;
const int MAXN = 1e5+1;
bool on[MAXN];
int current;
int query(int x) {
on[x] = !on[x];
current = Query(x);
return current;
}
void solve(int n, vi ls, vi rs) {
if(n==1) {
Answer(ls[0], rs[0]);
return;
}
vi Ls[2], Rs[2];
for(int i=0; i<n/2; ++i) {
query(ls[i]);
Ls[on[ls[i]]].push_back(ls[i]);
}
for(int i=n/2; i<n; ++i) {
Ls[on[ls[i]]].push_back(ls[i]);
}
for(int i=0; i<n; ++i) {
int old = current;
query(rs[i]);
if(current == old) {
Rs[1].push_back(rs[i]);
}
else {
Rs[0].push_back(rs[i]);
}
}
assert(Ls[0].size() == Rs[0].size() && Ls[1].size() == Rs[1].size());
solve(Ls[0].size(), Ls[0], Rs[0]);
solve(Ls[1].size(), Ls[1], Rs[1]);
}
void Solve(int N) {
vi ls={}, rs={};
int val = 0;
for(int i=1; i<=2*N; ++i) {
int nval = query(i);
if(nval == val) {
rs.push_back(i);
}
else {
ls.push_back(i);
}
val = nval;
}
solve(N, ls, rs);
}
# | 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... |