Submission #634184

#TimeUsernameProblemLanguageResultExecution timeMemory
634184flappybirdRarest Insects (IOI22_insects)C++17
0 / 100
1 ms208 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; #define MAX 2020 int chk[MAX]; int num[MAX]; int min_cardinality(int N) { int K; K = 0; int i; int on = 0; for (i = 0; i < N; i++) { move_inside(i); if (press_button() > 1) move_outside(i); else num[i] = 1, chk[i] = 1, on++; } int l, r; K = on; l = 0, r = N / K; while (r - l > 1) { int mid = (l + r + 1) / 2; vector<int> nb; for (i = 0; i < N; i++) { if (!chk[i] && !num[i]) { move_inside(i); if (press_button() > mid) { nb.push_back(i); move_outside(i); } on++; } if (on == mid * K) break; } if (on == mid * K) { for (i = 0; i < N; i++) if (chk[i]) num[i] = 1; l = mid; } else { for (auto v : nb) num[v] = -1; for (i = 0; i < N; i++) if (chk[i] && !num[i]) chk[i] = 0, move_outside(i), on--; } } return r; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...