Submission #755484

#TimeUsernameProblemLanguageResultExecution timeMemory
755484Godgift42Cave (IOI13_cave)C++14
100 / 100
222 ms472 KiB
#include "cave.h" using namespace std; void exploreCave(int N) { int s[N]; int d[N]; int c[N]; for(int i=0;i<N;i++){ s[i]=0; c[i]=0; } for(int i=0;i<N;i++){ int e = tryCombination(s); if(e==i){ for(int j=0;j<N;j++){ if(!c[j]){ if(s[j]==0) s[j]++; else s[j]--; } } } int l=0;int r=N-1; int pre=1; int t; while(l<r){ t=(l+r)/2; for(int j=l;j<=t;j++){ if(!c[j]){ if(s[j]==0) s[j]++; else s[j]--; } } e = tryCombination(s); if(e==i) e=0; else e=1; if((e==0 and pre==1) or (e==1 and pre==0)){ r=t; pre=e; } else{ l = t+1; pre=e; } } d[l]=i; c[l]=1; if(pre==0){ if(s[l]==0) s[l]++; else s[l]--; } } answer(s,d); }
#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...