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 "cave.h"
#include <cstring>
#include <vector>
#include <numeric>
#include <cassert>
void exploreCave(int N)
{
int S[N], D[N]; // vla legal ?
memset(S, 0, sizeof S);
std::vector<int> cand(N);
std::iota(cand.begin(), cand.end(), 0);
for(int i=0;i<N;++i)
{
int v = tryCombination(S);
assert(v == -1 || v >= i);
bool down = v==i;
int l=0, r=cand.size();
for(;r-l>1;)
{
int m=l+(r-l)/2;
for(int j=l;j<m;++j) S[cand[j]]^=1;
v = tryCombination(S);
for(int j=l;j<m;++j) S[cand[j]]^=1;
if((v==i) == down)
l=m;
else
r=m;
}
if(down)
S[l] ^= 1;
D[cand[l]]=i;
cand.erase(cand.begin()+l);
}
answer(S, D);
}
# | 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... |