#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
int N;
bool check_state(int* test, int idx){
int first = tryCombination(test);
if(first == -1) return false;
if(first >= idx) return false;
return true;
}
bool can(int lo, int mid, int hi, char side, bool state, int idx){
int test[N] = {0};
if(side == 'L'){
for(int i = lo; i < mid; ++i)
test[i] = 1;
}
else{
for(int i = mid; i <= hi; ++i)
test[i] = 1;
}
bool new_state = check_state(test,idx);
if (state != new_state) return true;
return false;
}
int bs(bool state, int idx, char side){
int hi = N-1, lo = 0, mid = lo + (hi - lo) / 2, ans = -1;
while(hi <= lo){
if (can(lo, mid, hi, side, state, idx))
{ans = mid; mid = hi - 1; side = 'L';}
else
{mid = lo + 1; side = 'R';}
}
return ans;
}
void exploreCave(int n) {
N = n;
int S[N] = {0}, D[N] = {0};
for(int i = 0; i < N; ++i){
bool state = check_state(S,i); // 0 = open, 1 = closed
char side = 'L';
if(state) S[i] = 1;
D[i] = bs(state,i,side);
}
answer(S,D);
}
Compilation message
dreaming.cpp:1:10: fatal error: cave.h: No such file or directory
1 | #include "cave.h"
| ^~~~~~~~
compilation terminated.