# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
745474 | AndrijaM | Cave (IOI13_cave) | C++14 | 0 ms | 0 KiB |
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"
#include<bits/stdc++.h>
using namespace std;
void exploreCave(int N) {
int pos[N],a[N],i,j,l,r,m;
for(int i=0;i<=N;i++) a[i]=0,pos[i]=-1;
for(i=0;i<N;i++){
l=0;
r=N-1;
bool k=(tryCombination(a)==i);
while(l<r){
m=l+(r-l)/2;
for(j=l;j<=m;j++)
if(pos[j]==-1) a[j]=1-a[j];
if((tryCombination(a)==i)==k) l=m+1;
else r=m;
for(j=l;j<=m;j++)
if(pos[j]==-1) a[j]=1-a[j];
}
pos[l]=i;
}
}
answer(a,pos);
}