Submission #154684

#TimeUsernameProblemLanguageResultExecution timeMemory
154684mhy908Cave (IOI13_cave)C++14
0 / 100
335 ms512 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; int point[5010]; bool ch[5010]; int p[5010], n; int binopen(int st, int fin, int num){ if(st==fin)return st; int mid=(st+fin)/2; for(int i=st; i<=mid; i++) if(!ch[i])p[i]=(p[i]+1)%2; int t=tryCombination(p); if(t==-1)t=n; for(int i=st; i<=mid; i++) if(!ch[i])p[i]=(p[i]+1)%2; if(t==num)return binopen(st, mid, num); return binopen(mid+1, fin, num); } int binclose(int st, int fin, int num){ if(st==fin)return st; int mid=(st+fin)/2; for(int i=st; i<=mid; i++) if(!ch[i])p[i]=(p[i]+1)%2; int t=tryCombination(p); for(int i=st; i<=mid; i++) if(!ch[i])p[i]=(p[i]+1)%2; if(t>num)return binclose(st, mid, num); return binclose(mid+1, fin, num); } void exploreCave(int N){ n=N; for(int i=0; i<n; i++){ int temp=tryCombination(p); if(temp==i){ int num=binclose(0, n-1, i); point[num]=i; ch[num]=true; p[i]=(p[i]+1)%2; } else{ int num=binopen(0, n-1, i); point[num]=i; ch[num]=true; } } answer(point, p); }
#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...