Submission #630798

#TimeUsernameProblemLanguageResultExecution timeMemory
630798MahtimursuRarest Insects (IOI22_insects)C++17
59.03 / 100
166 ms540 KiB
#include "insects.h" #include <vector> #include <algorithm> #include <bits/stdc++.h> using namespace std; vector<int> v; int inside = 0; mt19937 rng(chrono::system_clock::now().time_since_epoch().count()); int min_cardinality(int n) { int uniq = 0; for (int i = 0; i < n; ++i) { move_inside(i); if (press_button() > 1) { move_outside(i); v.push_back(i); } else uniq++; } if (uniq == 1) return n; if (uniq > n / 2) return 1; inside = uniq; int ans = 1; for (int k = 2 << 10; k >= 1; k /= 2) { if (ans + k > n / 2) continue; vector<int> in; int mx = ans + k; int gc = 0; shuffle(v.begin(), v.end(), rng); for (int x : v) { move_inside(x); if (press_button() > mx) { move_outside(x); } else { in.push_back(x); gc++; } } if ((inside + gc) / mx == uniq) { ans += k; inside += gc; for (int x : in) v.erase(find(v.begin(), v.end(), x)); } else { v = in; for (int x : in) move_outside(x); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...