Submission #708680

#TimeUsernameProblemLanguageResultExecution timeMemory
708680t6twotwo드문 곤충 (IOI22_insects)C++17
47.52 / 100
223 ms400 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; using ll = long long; int min_cardinality(int n) { vector<bool> in(n); for (int i = 0; i < n; i++) { move_inside(i); if (press_button() == 2) move_outside(i); else in[i] = 1; } int type = 0; for (int i = 0; i < n; i++) { if (in[i]) { type++; } } if (2 * type > n) return 1; auto noneed(in); bool flag = 1; int lo = 1, hi = n, cnt = type; while (lo < hi) { int x = (lo + hi + 1) / 2; if (!flag) { for (int i = 0; i < n; i++) { if (in[i]) { cnt--; in[i] = 0; move_outside(i); } } assert(!cnt); } for (int i = 0; i < n; i++) { if (in[i]) continue; move_inside(i); if (!noneed[i] && press_button() == x + 1) move_outside(i); else in[i] = 1, cnt++; } if (cnt == x * type) lo = x, flag = 1; else hi = x - 1, flag = 0; } return lo; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...