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"
const int SZ = 5010;
int s[SZ];
int d[SZ];
void flip(int i){
while(i >= 0){
if(d[i] == -1){
s[i] = !s[i];
}
--i;
}
}
void exploreCave(int N) {
for(int i = 0; i < N; ++i){
s[i] = 0; d[i] = -1;
}
for (int i = 0; i < N; ++i) {
int v = tryCombination(s);
if (v == i) flip(N);
int low = 0, high = N - 1, p = -1;
while (low <= high) {
int mid = (low + high) >> 1;
flip(mid);
v = tryCombination(s);
flip(mid);
if (v == i) high = (p = mid) - 1;
else low = mid + 1;
}
d[p] = i;
}
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... |