#include "cave.h"
#include <bits/stdc++.h>
int tog(int c) { return c == 0; }
void exploreCave(int n) {
// int s[n]; memset(s, 0, sizeof s);
int v[n]; memset(v, 0, sizeof v);
int vs[n]; memset(vs, 0, sizeof vs);
int d[n]; memset(d, 0, sizeof d);
for(int i = 0 ; i < n ; i++) {
int w[n]; memcpy(v, w, sizeof w);
int l = 0, r = n;
int k = tryCombination(w);
while(r > l) {
int m = (l+r)/2;
for(int j = 0 ; j < m ; j++) {
if(!vs[j]) {
w[j] = tog(w[j]);
}
}
int kv = tryCombination(w);
if(kv != k) r = m-1;
else l = m+1;
k = kv;
}
// s[l] = i;
if(k > i+1) v[l] = 1;
else v[l] = 0;
vs[l] = 1;
d[i] = l+1;
}
answer(v, 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... |