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 door[5001],a[5001];
bool ans[5001]; int where[5001];
void exploreCave(int N) {
for(int i=0;i<N;i++)
{
int s=0,e=N-1;
for(int j=0;j<N;j++)
if(ans[j]==0) a[j]=0;
int res=tryCombination(a);
if(res!=i)
{
for(int j=0;j<N;j++)
if(ans[j]==0) a[j]=1;
}
while(s<=e)
{
int mid=(s+e)/2;
for(int j=s;j<=mid;j++)
if(ans[j]==0) a[j]=!a[j];
int res=tryCombination(a);
if(res==i) // 뒷쪽에 있음
{
for(int j=s;j<=mid;j++)
if(ans[j]==0) a[j]=!a[j];
s=mid+1;
}
else // 앞쪽에 있음
{
for(int j=s;j<=mid;j++)
if(ans[j]==0) a[j]=!a[j];
e=mid;
}
}
ans[s]=true;
where[s]=i;
door[s]=!a[s];
}
answer(door,where);
}
# | 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... |