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 <iostream>
using namespace std;
int s[6000], d[6000], n;
bool sure[6000], to = 1;
void change(int l, int r) {
for(int i=l;i<=r;i++) {
if(!sure[i]) s[i] = 1-s[i];
}
}
int SwitchForDoor(int door) {
int cur = tryCombination(s);
if(cur>door || cur==-1) {
to = !to;
change(0, n-1);
}
int l = 0, r = n-1;
while(l<r) {
int m = (l+r)/2;
change(l, m);
cur = tryCombination(s);
change(l, m);
if(cur>door || cur==-1) {
r = m;
} else {
l = m+1;
}
}
return l;
}
void exploreCave(int N) {
n = N;
for(int i=0;i<n;i++) {
int sw = SwitchForDoor(i);
d[sw] = i;
sure[sw] = true;
s[sw] = to;
}
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... |