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"
inline int __lg(int n) { return 31 - __builtin_clz(n); }
int on[5025];
int D[5025], S[5025];
int n;
int checkPrefix(int x, int d) {
for(int i = 0; i < n; i++) {
if(D[i] == -1)
on[i] = (i < x) ^ d;
}
return tryCombination(on);
}
void exploreCave(int n) {
for(int i = 0; i < n; i++) D[i] = -1;
for(int now = 0; now < n; now++) {
if(checkPrefix(n, 0) == now) { // all on -> now should be off
int x = 0;
for(int s = 1<<__lg(n); s; s>>=1) if(x+s < n && checkPrefix(x+s, 0) != now) x += s;
D[x] = now;
S[x] = on[x] = 0;
} else {
int x = 0;
for(int s = 1<<__lg(n); s; s>>=1) if(x+s < n && checkPrefix(x+s, 1) != now) x += s;
D[x] = now;
S[x] = on[x] = 1;
}
}
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... |