Submission #240037

#TimeUsernameProblemLanguageResultExecution timeMemory
240037ctziapoCave (IOI13_cave)C++14
0 / 100
372 ms516 KiB
#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)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:6:9: warning: unused variable 'p' [-Wunused-variable]
     int p[n]={};
         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...