제출 #535394

#제출 시각아이디문제언어결과실행 시간메모리
535394AngusWong동굴 (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...