Submission #981490

#TimeUsernameProblemLanguageResultExecution timeMemory
981490batsukh2006Cave (IOI13_cave)C++17
100 / 100
264 ms604 KiB
#include "cave.h" #include<bits/stdc++.h> using namespace std; void exploreCave(int N){ int pos[N],ans[N]; vector<bool> vis(N); memset(pos,0,sizeof(pos)); for(int i=0; i<N; i++){ int tmp=0,p=0; if(tryCombination(pos)==i) tmp=1; int l=0,r=N-1; while(l<=r){ int m=l+(r-l)/2; for(int z=0; z<=m; z++){ if(!vis[z]) pos[z]^=1; } if(tmp){ if(tryCombination(pos)==i) l=m+1,p=pos[l]^1; else r=m-1,tmp^=1,p=pos[l]; }else{ if(tryCombination(pos)==i) r=m-1,p=pos[l]^1,tmp^=1; else l=m+1,p=pos[l]; } } vis[l]=1; ans[l]=i; pos[l]=p; } answer(pos,ans); }
#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...