Submission #823132

#TimeUsernameProblemLanguageResultExecution timeMemory
823132finn__Rarest Insects (IOI22_insects)C++17
100 / 100
48 ms456 KiB
#include <bits/stdc++.h> #include "insects.h" std::bitset<2000> in_machine, deleted; int min_cardinality(int N) { std::vector<int> j(N); std::iota(j.begin(), j.end(), 0); std::random_shuffle(j.begin(), j.end()); int d = 0; for (int const &i : j) { move_inside(i); if (press_button() > 1) move_outside(i); else ++d, in_machine[i] = 1; } int a = 1, b = N / d; while (a < b) { int const mid = (a + b + 1) >> 1; std::vector<int> moved; int inside = in_machine.count(); for (int const &i : j) { if (!deleted[i] && !in_machine[i]) { move_inside(i); if (press_button() > mid) move_outside(i); else in_machine[i] = 1, moved.push_back(i), ++inside; } if (inside == d * mid) break; } if (inside == d * mid) { a = mid; } else { b = mid - 1; deleted |= ~in_machine; for (auto const &i : moved) in_machine[i] = 0, move_outside(i); } } return a; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...