Submission #745060

#TimeUsernameProblemLanguageResultExecution timeMemory
745060math_rabbit_1028Rarest Insects (IOI22_insects)C++17
0 / 100
60 ms336 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; int types = 0, ch[2020], use[2020], cnt = 0; int min_cardinality(int N) { // calculate types: N times for (int i = 0; i < N; i++) { move_inside(i); if (press_button() >= 2) move_outside(i); else { ch[i] = 1; types++; cnt++; use[i] = 1; } } int st = 1, ed = N / types; while (st < ed) { int x = (st + ed + 1) / 2; for (int i = 0; i < N; i++) { if (ch[i] == 1) continue; move_inside(i); if (press_button() > x) move_outside(i); else { use[i] = 1; cnt++; } } if (cnt == x * types) { st = x; for (int i = 0; i < N; i++) if (use[i] == 1) ch[i] = 1; } else { ed = x - 1; for (int i = 0; i < N; i++) if (use[i] == 0) ch[i] = 1; for (int i = 0; i < N; i++) { if (ch[i] == 1) continue; move_outside(i); if (press_button() < x) move_inside(i); else { use[i] = 0; cnt--; } } } } return st; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...