# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
240037 | ctziapo | Cave (IOI13_cave) | C++14 | 372 ms | 516 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 "cave.h"
using namespace std;
void exploreCave(int N) {
int n=N;
int p[n]={};
int a[n]={};
int f[n];
for(int i=0;i<n;i++){
f[i]=-1;
}
int c=0;
int cou=0;
int t[n];
while(c<n-1){
for(int i=0;i<n;i++){
if(f[i]!=-1){
t[i]=f[i];
}
else
t[i]=0;
}
int t2=tryCombination(t);
//cout<<endl;
//cout<<"tosa me 0 : "<<t2<<" to c einai "<<c<<endl;
int one=0;
if(t2<=c)
one=1;
//cout<<"einai "<<one<<endl;
int l=0,r=n-1;
while(l<=r){
int mid=(l+r)/2;
for(int i=0;i<n;i++){
if(f[i]!=-1){
t[i]=f[i];
}
else{
if(i<=mid)
t[i]=one;
else
t[i]=(one+1)%2;
}
}
int t3=tryCombination(t);
//cout<<"dokimi me t3 : "<<t3<<" mid "<<mid<<endl;
for(int i=0;i<n;i++){
//cout<<t[i]<<" ";
}
//cout<<endl;
if(t3>c || t3==-1){
r=mid-1;
}
else
l=mid+1;
}
//cout<<"thesi old "<<l<<endl;
//cout<<"dokimi me final : "<<tryCombination(t)<<endl;
for(int i=0;i<n;i++){
//cout<<t[i]<<" ";
}
//cout<<endl;
//cout<<"thesi "<<l<<endl;
f[l]=one;
a[l]=cou;
//cout<<"cou "<<cou<<endl;
cou++;
c++;
}
int pos=0;
for(int i=0;i<n;i++){
if(f[i]!=-1){
t[i]=f[i];
}
else
pos=i;
}
//cout<<"position "<<pos<<" "<<t[pos]<<tryCombination(t);
if(tryCombination(t)!=-1){
t[pos]=(t[pos]+1)%2;
}
a[pos]=n-1;
answer(t,a);
}
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... |