Submission #786348

#TimeUsernameProblemLanguageResultExecution timeMemory
786348vjudge1Rarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int min_cardinality(int N) { int cnt = 0; vector<bool> f(N); for (int i = 0; i < N; i++) { move_inside(i); if (press_button() <= 1) { f[i] = 1; cnt++; } else { move_outside(i); } } vector<int> blocked(N); for (int i = 0; i < N; i++) { if (f[i]) { blocked[i] = 1; } } int lo = 1, hi = N / cnt, in = cnt, ad = 1; while (lo < hi) { int mi = (lo + hi + 1) / 2; vector<int> ord(N); iota(ord.begin(), ord.end(), 0); shuffle(ord.begin(), ord.end(), rng()); for (int i : ord) { if (f[i] || blocked[i]) { continue; } move_inside(i); if (press_button() <= mi) { in++; f[i] = 1; } else { move_outside(i); } } if (in == mi * cnt) { for (int i = 0; i < N; i++) { if (f[i]) { blocked[i] = 1; } } lo = mi; } else { hi = in / cnt; for (int i = 0; i < N; i++) { if (!f[i]) { blocked[i] = 1; } if (blocked[i]) { continue; } if (f[i]) { f[i] = 0; in--; move_outside(i); } } } } return lo; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:23:41: warning: unused variable 'ad' [-Wunused-variable]
   23 |     int lo = 1, hi = N / cnt, in = cnt, ad = 1;
      |                                         ^~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from insects.cpp:2:
/usr/include/c++/10/bits/stl_algo.h: In instantiation of 'void std::shuffle(_RAIter, _RAIter, _UGenerator&&) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _UGenerator = long unsigned int]':
insects.cpp:28:46:   required from here
/usr/include/c++/10/bits/stl_algo.h:3769:2: error: 'std::remove_reference<long unsigned int>::type' {aka 'long unsigned int'} is not a class, struct, or union type
 3769 |  __uc_type;
      |  ^~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3797:37: error: 'std::remove_reference<long unsigned int>::type' {aka 'long unsigned int'} is not a class, struct, or union type
 3797 |    const pair<__uc_type, __uc_type> __pospos =
      |                                     ^~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3797:37: error: 'std::remove_reference<long unsigned int>::type' {aka 'long unsigned int'} is not a class, struct, or union type