Submission #550041

#TimeUsernameProblemLanguageResultExecution timeMemory
550041paliloCave (IOI13_cave)C++17
0 / 100
295 ms340 KiB
#include "cave.h" #include <bits/stdc++.h> void exploreCave(int n) { using namespace std; vector s(n, -1), d(n, -1), vec(n, 0); auto solve = [&](int door_id) { // determine [start, n) transform(s.begin(), s.end(), vec.begin(), [&](const auto& x) { return x == -1 ? 0 : x; }); const int correct {tryCombination(vec.data()) == door_id}; const auto wrong = !correct; // auto interval {views::iota(0, n) | views::filter([&](const auto& i) { return s[i] == -1; })}; int lo = 0, hi = n - door_id; while (lo != hi) { const auto mid = (lo + hi) >> 1; int id = 0; for (int i = 0; i < n; ++i) { if (s[i] != -1) continue; vec[i] = id++ < mid ? correct : wrong; } // for (const auto& x : interval | views::take(mid)) { // vec[x] = correct; // } // for (const auto& x : interval | views::drop(mid)) { // vec[x] = wrong; // } tryCombination(vec.data()) == door_id ? hi = mid : lo = mid + 1; } s[lo] = correct; d[lo] = door_id; }; for (int i = 0; i < n; ++i) { solve(i); } // for (const auto& i : views::iota(0, n)) { // solve(i); // } answer(s.data(), d.data()); }
#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...