Submission #435547

#TimeUsernameProblemLanguageResultExecution timeMemory
435547CollypsoCounting Mushrooms (IOI20_mushrooms)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define vt vector #define pb push_back #define all(x) (x).begin(), (x).end() #define sz(x) (int) (x).size() #pragma GCC optimize ("O3") #pragma GCC optimize ("O2") #define F first #define S second //#define endl '\n' //#define int long long using namespace std; int use_machine(vt<int> x); int subtask1(int n) { int ans = 1; for(int i = 1; i < n - 1; i += 2) { int tmp = use_machine({i + 1, 0, i}); if (tmp == 0) ans += 2; else if (tmp == 1) ans += 1; } if (n % 2 == 0) ans += !use_machine({0, n - 1}); return ans; } //if (n <= 452) return subtask1(n); int count_mushrooms(int n) { vt<int> v[2]; v[0].pb(0); int q = 1, ans = 1, attempts = min(400, sqrt(n)); while(q < n && attempts--) { if (use_machine({0, q}) == 0) v[0].pb(q), ans++; else v[1].pb(q); q++; } int r = (sz(v[1]) > sz(v[0])) ? 1 : 0; int X = sz(v[r]); if (q >= n) return ans; for(int i = 0, to = (n - q + X - 2) / (X - 1); i < to; i++) { vt<int> tmp(1, v[r][0]); for(int j = 1; q < n && j < X; q++, j++) tmp.pb(q), tmp.pb(v[r][j]); if (r == 1) ans += use_machine(tmp) / 2; else ans += sz(tmp) / 2 - use_machine(tmp) / 2; //cout << ans << endl; //for(int x : tmp) cout << x << " "; //cout << endl; //cout << use_machine(tmp) << endl; } return ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:40:52: error: no matching function for call to 'min(int, __gnu_cxx::__enable_if<true, double>::__type)'
   40 |     int q = 1, ans = 1, attempts = min(400, sqrt(n));
      |                                                    ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from mushrooms.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:40:52: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'})
   40 |     int q = 1, ans = 1, attempts = min(400, sqrt(n));
      |                                                    ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from mushrooms.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:40:52: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'})
   40 |     int q = 1, ans = 1, attempts = min(400, sqrt(n));
      |                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:40:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   40 |     int q = 1, ans = 1, attempts = min(400, sqrt(n));
      |                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mushrooms.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:40:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   40 |     int q = 1, ans = 1, attempts = min(400, sqrt(n));
      |                                                    ^