Submission #627807

#TimeUsernameProblemLanguageResultExecution timeMemory
627807FischerRarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "insects.h" using namespace std; const int maxn = 2010; int in[maxn]; vector<bool> memo; int n; void put(int x) { memo[x] = 1; } void pop(int x) { memo[x] = 0; } map<vector<bool>, int> mapMemo; bool last[maxn]; int push() { if (mapMemo.contains(memo)) return mapMemo[memo]; for (int i = 0; i < n; ++i) { if (last[i] != (in[i] != 0)) { if (last[i]) move_outside(i); else move_inside(i); last[i] ^= 1; } } return mapMemo[memo] = press_button(); } bool p(int x) { int len = c; for (int i = 0; i < n; ++i) { if (in[i] == -1) continue; put(i); in[i] = 1; if (push() > x) { pop(i); in[i] = 0; } else { len += 1; } } for (int i = 0; i < n; ++i) { if (in[i] == 1) { pop(i); in[i] = 0; } } return len == x * c; } int min_cardinality(int N) { n = N; memo.assign(n, 0); c = 0; for (int i=0; i<N; ++i) { put(i); in[i] = -1; if (push() == 1) c += 1; else pop(i); } if (c == 1) return N; if (c == N) return 1; int lo = 2, hi = N / c; while (lo < hi) { int mid = (lo + hi + 1) / 2; if (p(mid, N)) lo = mid; else hi = mid-1; } return lo; }

Compilation message (stderr)

insects.cpp: In function 'int push()':
insects.cpp:21:15: error: 'class std::map<std::vector<bool>, int>' has no member named 'contains'
   21 |   if (mapMemo.contains(memo)) return mapMemo[memo];
      |               ^~~~~~~~
insects.cpp: In function 'bool p(int)':
insects.cpp:35:13: error: 'c' was not declared in this scope
   35 |   int len = c;
      |             ^
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:61:3: error: 'c' was not declared in this scope
   61 |   c = 0;
      |   ^
insects.cpp:75:17: error: too many arguments to function 'bool p(int)'
   75 |     if (p(mid, N)) lo = mid;
      |                 ^
insects.cpp:34:6: note: declared here
   34 | bool p(int x) {
      |      ^