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>
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
int pre, cur;
bool change(int x)
{
// cerr << "change " << x << '\n';
cur = Query(x);
swap(pre, cur);
return pre != cur;
}
void solve(vector<int> X, vector<int> Y, bool built)
{
if(X.size() == 1)
{
if(built)
change(X[0]), change(Y[0]);
Answer(X[0], Y[0]);
return;
}
int N = X.size(), mid = N / 2;
vector<int> lX(X.begin(), X.begin() + mid), rX(X.begin() + mid, X.end()), lY, rY;
if(built)
{
for(int i = mid; i < N; i++)
change(X[i]);
for(int i : Y)
if(change(i))
rY.emplace_back(i);
else
lY.emplace_back(i);
for(int i : lY)
change(i);
}
else
{
for(int i = 0; i < mid; i++)
change(X[i]);
for(int i : Y)
if(change(i))
rY.emplace_back(i);
else
lY.emplace_back(i);
for(int i : rY)
change(i);
}
solve(lX, lY, 1);
solve(rX, rY, 0);
}
void Solve(int N)
{
pre = cur = 0;
vector<int> X, Y;
for(int i = 1; i <= 2 * N; i++)
{
if(change(i))
X.emplace_back(i);
else
Y.emplace_back(i);
}
solve(X, Y, 1);
}
# | 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... |