# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
962704 | simona1230 | Cave (IOI13_cave) | C++17 | 679 ms | 600 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;
int n;
int c[5000],d[5000];
int p[5000],l[5000];
int used[5000];
void exploreCave(int N)
{
n=N;
int x=tryCombination(l);
if(x==-1)
{
x=0;
for(int i=0; i<n; i++)
c[i]=1;
}
for(int i=0; i<n-1; i++)
{
/*cout<<endl;
for(int j=0; j<n; j++)
cout<<c[j]<<" ";
cout<<endl;
for(int j=0; j<n; j++)
cout<<used[j]<<" ";
cout<<endl;
cout<<i<<" / "<<x<<endl;*/
int l=1,r=n-i;
while(l!=r)
{
int m=(l+r)/2;
int cnt=0;
for(int j=0; j<n; j++)
{
if(!used[j])
{
//cout<<"=-=- "<<j<<endl;
cnt++;
if(cnt>=l&&cnt<=m)p[j]=c[j]^1;
else p[j]=c[j];
}
else p[j]=c[j];
}
int y=tryCombination(p);
/*cout<<l<<" "<<m<<" "<<r<<endl;
for(int j=0; j<n; j++)
cout<<p[j]<<" ";
cout<<endl;
cout<<"* "<<y<<endl;*/
if(y==-1&&x==i||x==i&&x!=y||x>i&&x==y)
{
r=m;
}
else
{
l=m+1;
}
}
int cnt=0;
for(int j=0; j<n; j++)
{
if(!used[j])
{
cnt++;
if(cnt==l)
{
used[j]=1;
if(x==i)c[j]=1^c[j];
d[j]=i;
//cout<<"- "<<j<<endl;
}
}
}
x=tryCombination(c);
}
int lf=0;
for(int j=0;j<n;j++)
{
if(!used[j])
{
d[j]=n-1;
if(x!=-1)c[j]=c[j]^1;
lf=j;
}
}
answer(c,d);
}
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... |