Submission #937525

#TimeUsernameProblemLanguageResultExecution timeMemory
937525AlcabelCave (IOI13_cave)C++17
100 / 100
143 ms604 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; void exploreCave(int N) { vector<int> rest(N); iota(rest.begin(), rest.end(), 0); int S[N], D[N]; for (int i = 0; i < N; ++i) { S[i] = 0; } for (int i = 0; i < N; ++i) { int start = tryCombination(S); if (start == -1) { start = N; } int left = 0, right = rest.size(); while (right - left > 1) { int mid = left + (right - left) / 2; for (int j = left; j < mid; ++j) { S[rest[j]] = 1; } int closed = tryCombination(S); if (closed == -1) { closed = N; } for (int j = left; j < mid; ++j) { S[rest[j]] = 0; } if ((start == i && closed > i) || (start > i && closed == i)) { right = mid; } else { left = mid; } } D[rest[left]] = i; if (start == i) { S[rest[left]] = 1; } else { S[rest[left]] = 0; } swap(rest[left], rest.back()); rest.pop_back(); } 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...