# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
890063 | presko | 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 "grader.c"
bool found[6000];
int state[6000];
int swtch[6000];
bool start[6000];
int s[6000];
void fill(int ind,int n)
{
int l=0,r=n-1;
while(r!=l)
{
int mid=(l+r+1)/2;
for(int i=0;i<n;i++)
{
if(found[i]){s[i]=state[i];continue;}
if(i<mid)s[i]=1;
else s[i]=0;
}
int ans=tryCombination(s);
bool sta=0;
if(ans>ind)sta=1;
if(sta!=start[ind])r=mid-1;
else l=mid;
}
swtch[l]=ind;
found[l]=1;
state[l]=s[l];
}
void exploreCave(int N)
{
int res=tryCombination(s);
for(int i=0;i<res;i++)start[i]=1;
for(int i=0;i<N;i++)fill(i,N);
answer(state,swtch);
}