# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1113728 | 2024-11-17T08:55:35 Z | db_123 | Rarest Insects (IOI22_insects) | C++17 | 1 ms | 336 KB |
#include "insects.h" #include <vector> #include <set> #include <unordered_map> using namespace std; int n; void check(int N, int d, int &always_add, int &rsBs, vector<bool> &vis) { int mid = N / (2 * d); if(mid == 0) mid = 1; vector<int> poz; for (int i = 1; i <= n; i++) { if (vis[i]) { continue; } move_inside(i); if (press_button() > mid) { move_outside(i); continue; } poz.emplace_back(i); } for (auto it : poz) { move_outside(it); } if (poz.size() == mid * d) { /// e plin for (auto it : poz) { vis[it] = true; } always_add += poz.size() / d; } else if (poz.size() < mid * d) { /// nu e plin rsBs = min(rsBs, mid); int idx = 0; for (int i = 1; i <= n; i++) { if (vis[i]) { continue; } while (idx < poz.size() && poz[idx] < i) { idx ++; } if (poz[idx] != i) { vis[i] = true; } } } return; } int min_cardinality(int N) { vector<bool> vis(N + 1); n = N; int d = 0; { vector<int> temp; for (int i = 1; i <= n; i++) { move_inside(i); if (press_button() > 1) { move_outside(i); continue; } temp.emplace_back(i); } d = temp.size(); for (auto it : temp) { move_outside(it); } } int always_add = 0, rsBs = 1e9; while (N >= d) { check(N, d, always_add, rsBs, vis); int cnt = 0; for (int i = 1; i <= n; i++) { if (vis[i]) { continue; } cnt ++; } N = cnt; } return always_add; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | Integer 2 violates the range [0, 1] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | Integer 2 violates the range [0, 1] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 336 KB | Integer 6 violates the range [0, 5] |
2 | Halted | 0 ms | 0 KB | - |