Submission #313981

#TimeUsernameProblemLanguageResultExecution timeMemory
313981nonthaphatCounting Mushrooms (IOI20_mushrooms)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef double db; typedef pair<int, int> pii; typedef pair<int, ll> pil; typedef pair<ll, int> pli; typedef pair<ll, ll> pll; typedef pair<pii, int> piipi; typedef pair<int, pii> pipii; typedef pair<pii, pii> piipii; typedef pair<ll, pii> plpii; typedef pair<db, db> pdd; typedef pair<ld, ld> pldd; typedef vector<int> vi; typedef vector<pii> vii; #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define FOR2(i, a, b) for(int i=(a);i<=(b);++i) #define ROF(i, a, b) for(int i=(b)-1;i>=(a);--i) #define ROF2(i, a, b) for(int i=(b);i>=(a);--i) #define GO(i, x) for(auto &i : x) #define mp make_pair #define fi first #define se second #define sz(x) (int)x.size() #define all(x) (x).begin(), (x).end() #define eb emplace_back #define pf push_front #define pb push_back #define lb lower_bound #define up upper_bound template<typename T> inline bool min2(T &a, const T &b) { return b < a ? a = b, 1 : 0; } template<typename T> inline bool max2(T &a, const T &b) { return a < b ? a = b, 1 : 0; } const int mod = 1e9 + 7; // const int mod = 998244353; const int P1 = 999983, P2 = 999979; const ld PI = acos((ld)-1); const int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; const ll INF = 1e18; const int N = 1e6; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int M = 120; int use_machine(vector<int> x); int count_mushrooms(int n){ int count_A = 1, count_B = 0; int i = 1; vector<int> A, B; A.push_back(0); if(n <= 226){ while(i < n){ vector<int> x; x.push_back(0); x.push_back(i); int result = use_machine(x); if(result == 0){ A.push_back(i); count_A++; } else{ B.push_back(i); count_B++; } i++; } return count_A; } while(count_A < 2 && count_B < 2){ vector<int> x; x.push_back(0); x.push_back(i); int result = use_machine(x); if(result == 0){ A.push_back(i); count_A++; } else{ B.push_back(i); count_B++; } i++; } while(count_A < M && count_B < M){ bool sw = 0; if(count_A < count_B){ sw = 1; swap(A, B); swap(count_A, count_B); } vector<int> x; x.push_back(i); x.push_back(A[0]); x.push_back(i+1); x.push_back(A[1]); int result = use_machine(x); switch(result){ case 0: A.push_back(i); A.push_back(i+1); count_A += 2; break; case 1: B.push_back(i); A.push_back(i+1); count_A++; count_B++; break; case 2: A.push_back(i); B.push_back(i+1); count_A++; count_B++; break; default: B.push_back(i); B.push_back(i+1); count_B += 2; } if(sw){ swap(A, B); swap(count_A, count_B); } i += 2; } while(i < n){ bool sw = 0; if(A.size() < B.size()){ sw = 1; swap(A, B); swap(count_A, count_B); } vector<int> x; int L = min(A.size(), n-i); for(int j=0;j<L;j++){ x.push_back(i+j); x.push_back(A[j]); } int result = use_machine(x); if(result%2 == 0){ A.push_back(i); count_A++; } else{ B.push_back(i); count_B++; } count_B += result/2; count_A += (L-1) - result/2; if(sw){ swap(A, B); swap(count_A, count_B); } i += L; } return count_A; }

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:143:34: error: no matching function for call to 'min(std::vector<int>::size_type, int)'
  143 |         int L = min(A.size(), n-i);
      |                                  ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from mushrooms.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:143:34: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
  143 |         int L = min(A.size(), n-i);
      |                                  ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from mushrooms.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:143:34: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
  143 |         int L = min(A.size(), n-i);
      |                                  ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from mushrooms.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:143:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
  143 |         int L = min(A.size(), n-i);
      |                                  ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from mushrooms.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
mushrooms.cpp:143:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
  143 |         int L = min(A.size(), n-i);
      |                                  ^