Submission #1162444

#TimeUsernameProblemLanguageResultExecution timeMemory
1162444The_SamuraiRarest Insects (IOI22_insects)C++20
Compilation error
0 ms0 KiB
#include "insects.h" #include "bits/stdc++.h" using namespace std; mt19937 rng(time(0)); int rand(int l, int r) { int x = rng(); x = abs(x); return x % (r - l + 1) + l; } int min_cardinality(int n) { vector<int> ord(n); iota(ord.begin(), ord.end(), 0); for (int i = 1; i < n; i++) swap(ord[i], ord[rand(0, i)]); vector<bool> vis(n); vector<int> pos = {0}; move_inside(0); for (int i = 1; i < n; i++) { move_inside(i); int x = press_button(); if (x > 1) { move_outside(i); } else { pos.emplace_back(i); } } for (int x: pos) vis[x] = true; int sq = min(n, 2 * sqrt(n)); if (pos.size() <= sq) { int ans = 1e9; for (int t = 0; t < pos.size(); t++) { int old = 1; vector<int> added; for (int i: ord) { if (vis[i]) continue; move_inside(i); int nw = press_button(); if (nw == old) { move_outside(i); } else { added.emplace_back(i); vis[i] = true; old = nw; // if (nw >= ans) break; } } for (int x: added) move_outside(x); ans = min(ans, old); if (ans == 1) break; } return ans; } if (pos.size() == 1) return n; if (pos.size() == n) return 1; auto ok = [&](int mid) -> bool { int cnt = count(vis.begin(), vis.end(), true); vector<int> added; for (int i: ord) { if (vis[i]) continue; move_inside(i); int now = press_button(); if (now > mid) { move_outside(i); } else { added.emplace_back(i); cnt++; } } if (cnt == mid * pos.size()) { for (int x: added) vis[x] = true; return true; } for (int x: added) move_outside(x); return false; }; int lx = 2, rx = n / pos.size(), best = 1; while (lx <= rx) { int mid = (lx + rx) >> 1; if (ok(mid)) { best = mid; lx = mid + 1; } else { rx = mid - 1; } } return best; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:29:17: error: no matching function for call to 'min(int&, __gnu_cxx::__enable_if<true, double>::__type)'
   29 |     int sq = min(n, 2 * sqrt(n));
      |              ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from insects.cpp:2:
/usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
insects.cpp:29:17: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'})
   29 |     int sq = min(n, 2 * sqrt(n));
      |              ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from insects.cpp:2:
/usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
insects.cpp:29:17: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'})
   29 |     int sq = min(n, 2 * sqrt(n));
      |              ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from insects.cpp:2:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
insects.cpp:29:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |     int sq = min(n, 2 * sqrt(n));
      |              ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from insects.cpp:2:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
insects.cpp:29:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |     int sq = min(n, 2 * sqrt(n));
      |              ~~~^~~~~~~~~~~~~~~~