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"
bool found[6000];
int state[6000];
int swtch[6000];
bool start[6000];
int s[6000];
int ga[6000];
int fil(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 || ans==-1)sta=1;
if(sta!=start[ind])r=mid-1;
else l=mid;
}
swtch[l]=ind;
found[l]=1;
if(start[ind]==1)state[l]=0;
else state[l]=1;
return l;
}
void exploreCave(int N)
{
for(int i=0;i<N;i++)
{
int res=tryCombination(ga);
if(res==-1)res=N;
for(int j=0;j<res;j++)start[j]=1;
for(int j=res;j<N;j++)start[j]=0;
int x=fil(i,N);
ga[x]=state[x];
}
answer(state,swtch);
}
# | 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... |