#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef tuple<ll, ll, ll> plll;
typedef vector<plll> vplll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vector<pll>> vvpll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
#define loop(i, s, e) for (ll i = (s); i < (e); ++i)
#define loopr(i, e, s) for (ll i = (e)-1; i >= (s); --i)
#define all(a) a.begin(), a.end()
const ll inf = 1e9 + 7;
#include "cave.h"
ll s[5000];
vll pos;
vb ass;
ll n;
void update(ll i,ll endi) {
 for (;i<=endi ;i++) {
   if (!ass[i]) s[i] = (s[i]==0?1:0);
 }
}
ll bl(ll i) {
  ll l = 0, r =n-1;
  while (l<=r) {
      if(l==r) {
          ass[l] = 1;
          pos[l] = i;
          return l;
      }
    ll t = tryCombination(s);
    ll mid = (r+l)/2;
    update(l,mid);
    ll t1 = tryCombination(s);
    if (t1==-1) t1 =n;
    if (t==-1) t =n;
    if ((t1==i && t>i) || (t==i && t1>i)) {
      r = mid;
    }
    else l = mid+1;
  }
    ass[l] = 1;
    pos[l] = i;
    return l;
}
void exploreCave(int N) {
  n= N;
  pos.resize(n);
  ass.resize(n);
  memset(s, 0, sizeof(s));
  loop(i,0,n) {
   ll c=  bl(i);
    if (tryCombination(s)==i)  s[c] = (s[c]==0?1:0);
  }
  ll posi[n];
  loop(i,0,n) posi[i] = pos[i];
  answer(s, posi);
}
| # | 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... |