Submission #163131

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