#include <bits/stdc++.h>
using namespace std;
#include "cave.h"
void exploreCave(int n){
int s[n], d[n];
for(int i = 0; i < n; i++) s[i] = 0, d[i] = 0;
vector<bool> known(n, false);
int cr[n];
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++) {
if(!known[j]) s[j] = 0;
else s[j] = cr[j];
}
int calm = tryCombination(s);
if(calm == i) calm = -1;
else calm = 1;
int l = 0, r = n-1;
int res = calm;
while(l < r){
int m = (l+r+1)>>1;
for(int j = m; j <= r; j++){
if(!known[j]) s[j] = !s[j];
else s[j] = cr[j];
}
res = tryCombination(s);
if(res == i) res = -1;
else res = 1;
if(res != calm){
l = m;
}
else{
r = m-1;
}
calm = res;
}
r = max(r, 0);
d[r] = i;
if(res == -1) cr[r] = !s[r];
else cr[r] = s[r];
known[r] = true;
}
answer(cr, 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... |