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"
int ans[5010], sw[5010], chk[5010];
bool havethisbit(int x, int d){
return (x & (1 << d)) != 0;
}
void exploreCave(int N) {
int n = N;
if(n == 1){
ans[0] = 0;
sw[0] = 0;
if(tryCombination(sw) != -1) sw[0] = 1;
answer(sw, ans);
return;
}
int maxbit;
for(maxbit = 0; (1 << maxbit) < n; maxbit++);
int curans, cursw = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(chk[j]) continue;
else sw[j] = 0;
}
if(tryCombination(sw) == i) curans = 1;
else curans = 0;
for(int j = 0; j < maxbit; j++){
for(int k = 0; k < n; k++){
if(chk[k]) continue;
if(havethisbit(k, j)) sw[k] = curans;
else sw[k] = !(curans);
}
if(tryCombination(sw) != i) cursw += (1 << j);
}
ans[cursw] = i;
sw[cursw] = curans;
chk[cursw] = 1;
cursw = 0;
}
answer(sw, ans);
}
# | 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... |