Submission #436572

#TimeUsernameProblemLanguageResultExecution timeMemory
436572erekleCave (IOI13_cave)C++17
100 / 100
569 ms712 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; void exploreCave(int N) { int query[N] {}; set<int> indices; for (int i = 0; i < N; ++i) indices.insert(i); int correctPos[N], door[N]; // find switch of each door in order of doors for (int d = 0; d < N; ++d) { // find correct position of door vector<int> v(indices.begin(), indices.end()); int n = N-d; for (int i : v) query[i] = 0; int correct = (tryCombination(query) == d ? 1 : 0); int left = 0, right = n; while (right - left > 1) { int mid = (left + right) / 2; for (int i = left; i < mid; ++i) query[v[i]] = correct; for (int i = mid; i < right; ++i) query[v[i]] = 1-correct; if (tryCombination(query) == d) left = mid; else right = mid; } door[v[left]] = d; correctPos[v[left]] = correct; indices.erase(v[left]); query[v[left]] = correct; } answer(correctPos, door); }
#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...