Submission #1113724

#TimeUsernameProblemLanguageResultExecution timeMemory
1113724db_123Rarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include "insects.h" #include <vector> #include <set> #include <unordered_map> using namespace std; 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); 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 (stderr)

insects.cpp: In function 'void check(int, int, int&, int&, std::vector<bool>&)':
insects.cpp:15:26: error: 'n' was not declared in this scope
   15 |     for (int i = 1; i <= n; i++) {
      |                          ^
insects.cpp:31:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |     if (poz.size() == mid * d) { /// e plin
      |         ~~~~~~~~~~~^~~~~~~~~~
insects.cpp:37:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |     else if (poz.size() < mid * d) { /// nu e plin
      |              ~~~~~~~~~~~^~~~~~~~~
insects.cpp:41:30: error: 'n' was not declared in this scope
   41 |         for (int i = 1; i <= n; i++) {
      |                              ^
insects.cpp:45:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             while (idx < poz.size() && poz[idx] < i) {
      |                    ~~~~^~~~~~~~~~~~
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:63:30: error: 'n' was not declared in this scope
   63 |         for (int i = 1; i <= n; i++) {
      |                              ^
insects.cpp:81:30: error: 'n' was not declared in this scope
   81 |         for (int i = 1; i <= n; i++) {
      |                              ^