Submission #716664

#TimeUsernameProblemLanguageResultExecution timeMemory
716664TheSahibCave (IOI13_cave)C++17
100 / 100
265 ms468 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; void exploreCave(int N) { int S[N]; memset(S, 0, sizeof(S)); vector<int> switches(N); for (int i = 0; i < N; i++) { switches[i] = i; } int ans[N]; for (int i = 0; i < N; i++) { for(int a:switches){ S[a] = 0; } if(tryCombination(S) != i){ for(int a:switches){ S[a] = 1; } } int l = 0, r = switches.size() - 1; while(l < r){ int mid = (l + r) / 2; for(int j = l; j <= mid; j++){ S[switches[j]] ^= 1; } int t = tryCombination(S); for(int j = l; j <= mid; j++){ S[switches[j]] ^= 1; } if(t != i) r = mid; else l = mid + 1; } S[switches[l]] ^= 1; ans[switches[l]] = i; switches.erase(switches.begin() + l); } answer(S, ans); }
#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...