Submission #163132

#TimeUsernameProblemLanguageResultExecution timeMemory
163132mhy908Cave (IOI13_cave)C++14
0 / 100
56 ms512 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; int now[5010], where[5010], n; bool ch[5010]; void rev(int a, int b){ for(int i=a; i<=b; i++)if(!ch[i])now[i]^=1; } int tryc(int S[]){ int tmp=tryCombination(now); if(tmp==-1)return n; return tmp; } int binsearch(int st, int fin, bool fl, int num){ if(st==fin)return st; int mid=(st+fin)/2; if(fl){ rev(st, mid); if(tryc(now)!=num){ rev(st, mid); return binsearch(st, mid, fl, num); } rev(st, mid); return binsearch(mid+1, fin, fl, num); } else{ rev(st, mid); if(tryc(now)==num){ rev(st, mid); return binsearch(st, mid, fl, num); } rev(st, mid); return binsearch(mid+1, fin, fl, num); } } void exploreCave(int _n){ n=_n; for(int i=0; i<n; i++){ int temp=tryc(now); int but=binsearch(0, n-1, temp==i, i); if(temp==i){ where[but]=i; ch[but]=true; } else{ where[but]=i; rev(but, but); ch[but]=true; } } answer(now, where); }
#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...