Submission #1224174

#TimeUsernameProblemLanguageResultExecution timeMemory
1224174Sharky드문 곤충 (IOI22_insects)C++20
Compilation error
0 ms0 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; void conv(set<int> a, set<int> b) { vector<int> er; for (auto& x : a) if (!b.count(x)) move_outside(x); for (auto& x : b) if (!a.count(x)) move_inside(x); } set<int> cur; vector<int> index; random_device rd; mt19937 g(rd()); int min_cardinality(int N) { set<int> base; for (int i = 0; i < N; i++) { move_inside(i); if (press_button() == 1) base.insert(i); else move_outside(i); index.push_back(i); } vector<bool> bye(N, 0); int sz = base.size(); cur = base; int lo = 2, hi = N / sz; while (lo < hi) { int mid = (lo + hi + 1) / 2; conv(cur, base); cur = base; vector<int> vt; shuffle(index.begin(), index.end(), g); for (int x = 0; x < N; x++) { int i = index[x]; if (cur.count(i) || bye[i]) continue; if (cur.size() == sz * mid) { vt.push_back(i); continue; } move_inside(i); if (press_button() <= mid) cur.insert(i); else { move_outside(i); vt.push_back(i); } } if (cur.size() == sz * mid) { base = cur; lo = mid; } else { for (auto& x : vt) bye[x] = 1; hi = (cur.size() / sz); } } return lo; }

Compilation message (stderr)

insects.cpp:12:13: error: 'std::vector<int> index' redeclared as different kind of entity
   12 | vector<int> index;
      |             ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/11/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:48,
                 from insects.cpp:2:
/usr/include/strings.h:61:1: note: previous declaration 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:23:15: error: overloaded function with no contextual type information
   23 |         index.push_back(i);
      |               ^~~~~~~~~
insects.cpp:34:23: error: overloaded function with no contextual type information
   34 |         shuffle(index.begin(), index.end(), g);
      |                       ^~~~~
insects.cpp:34:38: error: overloaded function with no contextual type information
   34 |         shuffle(index.begin(), index.end(), g);
      |                                      ^~~
insects.cpp:36:26: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   36 |             int i = index[x];
      |                          ^