Submission #659889

#TimeUsernameProblemLanguageResultExecution timeMemory
659889peijarRarest Insects (IOI22_insects)C++17
47.51 / 100
255 ms424 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int min_cardinality(int N) { vector<int> roots; int nbCC = 0; for (int i = 0; i < N; ++i) { move_inside(i); if (i and press_button() == 2) move_outside(i); else roots.push_back(i), nbCC++; } vector<bool> isRoot(N); for (int r : roots) isRoot[r] = true; int lo = 1, up = N / nbCC; while (lo < up) { int mid = (lo + up + 1) / 2; int popped = 0; vector<int> toPop; for (int i = 0; i < N; ++i) if (!isRoot[i]) { move_inside(i); if (press_button() > mid) move_outside(i), popped++; else toPop.push_back(i); } for (int i : toPop) move_outside(i); if (popped == N - nbCC * mid) lo = mid; else up = mid - 1; } return lo; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...