Submission #745051

#TimeUsernameProblemLanguageResultExecution timeMemory
745051math_rabbit_1028Rarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 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; bool add = true; 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; if (use[i] == 1) { move_outside(i); cnt--; use[i] = 0; } } } return st; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:43:25: error: 'n' was not declared in this scope
   43 |     for (int i = 0; i < n; i++) {
      |                         ^
insects.cpp:23:8: warning: unused variable 'add' [-Wunused-variable]
   23 |   bool add = true;
      |        ^~~