Submission #1113723

#TimeUsernameProblemLanguageResultExecution timeMemory
1113723db_123Rarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include "insects.h" #include <vector> #include <set> #include <unordered_map> void check(int N, int d, int &always_add, int &rsBs, vector<bool> &vis) { ++cnt; if(cnt > 10) exit(0); 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:6:54: error: 'vector' has not been declared
    6 | void check(int N, int d, int &always_add, int &rsBs, vector<bool> &vis) {
      |                                                      ^~~~~~
insects.cpp:6:60: error: expected ',' or '...' before '<' token
    6 | void check(int N, int d, int &always_add, int &rsBs, vector<bool> &vis) {
      |                                                            ^
insects.cpp: In function 'void check(int, int, int&, int&, int)':
insects.cpp:8:11: error: 'cnt' was not declared in this scope; did you mean 'int'?
    8 |         ++cnt;
      |           ^~~
      |           int
insects.cpp:10:13: error: 'exit' was not declared in this scope
   10 |             exit(0);
      |             ^~~~
insects.cpp:16:9: error: 'vector' was not declared in this scope
   16 |         vector<int> poz;
      |         ^~~~~~
insects.cpp:16:9: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from insects.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from insects.cpp:2:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
insects.cpp:16:16: error: expected primary-expression before 'int'
   16 |         vector<int> poz;
      |                ^~~
insects.cpp:17:30: error: 'n' was not declared in this scope
   17 |         for (int i = 1; i <= n; i++) {
      |                              ^
insects.cpp:18:17: error: 'vis' was not declared in this scope
   18 |             if (vis[i]) {
      |                 ^~~
insects.cpp:26:13: error: 'poz' was not declared in this scope
   26 |             poz.emplace_back(i);
      |             ^~~
insects.cpp:29:24: error: 'poz' was not declared in this scope
   29 |         for (auto it : poz) {
      |                        ^~~
insects.cpp:33:13: error: 'poz' was not declared in this scope
   33 |         if (poz.size() == mid * d) { /// e plin
      |             ^~~
insects.cpp:35:17: error: 'vis' was not declared in this scope
   35 |                 vis[it] = true;
      |                 ^~~
insects.cpp:40:20: error: 'min' was not declared in this scope; did you mean 'std::min'?
   40 |             rsBs = min(rsBs, mid);
      |                    ^~~
      |                    std::min
In file included from /usr/include/c++/10/vector:60,
                 from insects.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: 'std::min' declared here
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
insects.cpp:43:34: error: 'n' was not declared in this scope
   43 |             for (int i = 1; i <= n; i++) {
      |                                  ^
insects.cpp:44:21: error: 'vis' was not declared in this scope
   44 |                 if (vis[i]) {
      |                     ^~~
insects.cpp:51:21: error: 'vis' was not declared in this scope
   51 |                     vis[i] = true;
      |                     ^~~
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:60:9: error: 'vector' was not declared in this scope
   60 |         vector<bool> vis(N + 1);
      |         ^~~~~~
insects.cpp:60:9: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from insects.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from insects.cpp:2:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
insects.cpp:60:16: error: expected primary-expression before 'bool'
   60 |         vector<bool> vis(N + 1);
      |                ^~~~
insects.cpp:64:20: error: expected primary-expression before 'int'
   64 |             vector<int> temp;
      |                    ^~~
insects.cpp:65:34: error: 'n' was not declared in this scope
   65 |             for (int i = 1; i <= n; i++) {
      |                                  ^
insects.cpp:71:17: error: 'temp' was not declared in this scope
   71 |                 temp.emplace_back(i);
      |                 ^~~~
insects.cpp:73:17: error: 'temp' was not declared in this scope
   73 |             d = temp.size();
      |                 ^~~~
insects.cpp:81:43: error: 'vis' was not declared in this scope
   81 |             check(N, d, always_add, rsBs, vis);
      |                                           ^~~
insects.cpp:83:34: error: 'n' was not declared in this scope
   83 |             for (int i = 1; i <= n; i++) {
      |                                  ^