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"
int bt[5001];
int used[5001];
int right[5001];
bool used_key[5001];
void exploreCave(int N)
{
for(int i=0;i<N;i++)
{
used[i]=-1;
}
int l=0,r=N-1;
for(int j=0;j<N;j++)
{
l=0;
r=N-1;
// int mid=(l+r)/2;
bool fl=0;
for(int i=0;i<N;i++)
{
if(used_key[i]==0) bt[i]=0;
}
int curr=tryCombination(bt);
if(curr==j) fl=1;
while(l!=r)
{
int mid=(l+r)/2;
for(int i=0;i<N;i++)
{
if(used_key[i]==0) bt[i]=0;
}
for(int i=l;i<=mid;i++)
{
if(used_key[i]==0) bt[i]=1;
}
if((tryCombination(bt)!=j)!=fl)
{
l=mid+1;
}
else
{
// l=mid+1;
r=mid;
}
}
used[j]=l;
used_key[l]=true;
if(fl==1) bt[l]=1;
else bt[l]=0;
// printf("%dth bit is %d and used[%d]=%d\n",l,bt[l],j,used[j]);
}
for(int i=0;i<N;i++)
{
right[used[i]]=i;
}
answer(bt,right);
}
# | 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... |