Submission #535394

#TimeUsernameProblemLanguageResultExecution timeMemory
535394AngusWongCave (IOI13_cave)C++17
100 / 100
210 ms620 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; void exploreCave(int n) { int s[n], d[n], comb[n]; vector<int> switches; for (int i=0; i<n; i++) switches.push_back(i); for (int door=0; door<n; door++){ for (int i: switches) comb[i]=0; if (tryCombination(comb)==door){ for (int i: switches) comb[i]=1; } int l=0, r=switches.size()-1, mid; while (l<r){ mid=(l+r)/2; for (int i=mid+1; i<=r; i++) comb[switches[i]]=1-comb[switches[i]]; if (tryCombination(comb)==door){ for (int i=mid+1; i<=r; i++) comb[switches[i]]=1-comb[switches[i]]; l=mid+1; }else{ r=mid; } } s[switches[l]]=comb[switches[l]]; d[switches[l]]=door; switches.erase(switches.begin()+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...