Submission #627937

#TimeUsernameProblemLanguageResultExecution timeMemory
627937lunchboxRarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef vector<int> vi; #ifdef LOCAL void move_inside(int i); void move_outside(int i); int press_button(); #endif int min_cardinality(int n) { int c = 0; vi u, v, in(n), p(n); iota(p.begin(), p.end(), 0); for (int i = 0; i < n; i++) { move_inside(p[i]); if (press_button() == 1) { c++; in[i] = 1; } else { move_outside(p[i]); u.push_back(i); } } int low = 2, hi = n / c, sz = 0, ans = 1; while (low <= hi) { int t = (low + hi) / 2; v.clear(); shuffle(u.begin(), u.end(), rng); for (int i : u) { if (in[i]) continue; move_inside(p[i]); if (press_button() > t) { move_outside(p[i]); v.push_back(i); } else sz++; } if (c + sz == t * c) { fill(in.begin(), in.end(), 1); for (int i : v) in[i] = 0; ans = t; low = t + 1; } else { hi = t - 1; if (low <= hi) { for (int i : v) in[i] = 1; for (int i : u) if (!in[i]) { move_outside(p[i]); sz--; } } } } return ans; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:19:5: error: 'move_inside' was not declared in this scope
   19 |     move_inside(p[i]);
      |     ^~~~~~~~~~~
insects.cpp:20:9: error: 'press_button' was not declared in this scope
   20 |     if (press_button() == 1) {
      |         ^~~~~~~~~~~~
insects.cpp:24:7: error: 'move_outside' was not declared in this scope
   24 |       move_outside(p[i]);
      |       ^~~~~~~~~~~~
insects.cpp:36:7: error: 'move_inside' was not declared in this scope
   36 |       move_inside(p[i]);
      |       ^~~~~~~~~~~
insects.cpp:37:11: error: 'press_button' was not declared in this scope
   37 |       if (press_button() > t) {
      |           ^~~~~~~~~~~~
insects.cpp:38:9: error: 'move_outside' was not declared in this scope
   38 |         move_outside(p[i]);
      |         ^~~~~~~~~~~~
insects.cpp:56:13: error: 'move_outside' was not declared in this scope
   56 |             move_outside(p[i]);
      |             ^~~~~~~~~~~~