# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
245782 | uacoder123 | Cave (IOI13_cave) | C++14 | 247 ms | 640 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 <bits/stdc++.h>
#include <cave.h>
using namespace std;
void exploreCave(int N) {
int n=N,co=0,ch=0;
int arr[n]={},dno[n],f[n]={};
while(co!=n)
{
int d=tryCombination(arr);
if(d==-1)
{
ch=1;
break;
}
int l=0,r=n-1,ans;
while(l<r)
{
int m=(l+r+1)/2;
for(int i=m;i<=r;++i)
if(!f[i])
arr[i]^=1;
int res=tryCombination(arr);
if(res==-1)
{
ch=1;
break;
}
if(res<d)
{
d=res;
l=m;
}
else if(res==d)
{
r=m-1;
}
else
{
for(int i=m;i<=r;++i)
if(!f[i])
arr[i]^=1;
l=m;
}
}
if(ch)
break;
ans=l;
f[ans]=1;
dno[ans]=d;
arr[ans]^=1;
co++;
}
if(co==n)
{
answer(arr,dno);
exit(0);
}
else
{
for(int i=0;i<n;++i)
{
if(!f[i])
{
arr[i]^=1;
dno[i]=tryCombination(arr);
arr[i]^=1;
}
}
answer(arr,dno);
exit(0);
}
}
Compilation message (stderr)
# | 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... |