Submission #1049619

#TimeUsernameProblemLanguageResultExecution timeMemory
1049619LittleOrangeThe Big Prize (IOI17_prize)C++17
Compilation error
0 ms0 KiB
#include "prize.h" #include<bits/stdc++.h> using namespace std; using ll = int; int find_best(int n) { mt19937_64 mt(random_device{}()); vector<array<ll,2>> mem(n,{-1,-1}); auto qry = [&](ll i){ if (mem[i][0]==-1){ auto a = ask(i); mem[i] = {a[0],a[1]}; } return mem[i]; }; ll cnt = 449; vector<ll> a(n); iota(a.begin(),a.end(),0); shuffle(a.begin(),a.end(),mt); ll mx = 0; for(ll i = 0;i<cnt;i++){ mx = max(mx,qry(a[i])); } ll ans = -1; function<void(ll,ll,ll,ll)> dfs; dfs = [&](ll l, ll r,ll dl, ll dr){ if (ans != -1) return; if (l == r){ ans = l; return; } array<ll,2> o = {-1,-1}; ll m = l+r>>1; while(o[0]+o[1]!=0&&o[0]+o[1]!=mx){ m = l+mt()%(r-l+1); o = qry(m); } if (o[0]+o[1]==0) { ans = m; return; } if (o[0]-dl>0){ dfs(l,m-1,dl,o[1]); } if(o[1]-dr>0){ dfs(m+1,r,o[0],dr); } }; dfs(0,n-1,0,0); return ans; }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:21:24: error: no matching function for call to 'max(ll&, std::array<int, 2>)'
   21 |   mx = max(mx,qry(a[i]));
      |                        ^
In file included from /usr/include/c++/10/vector:60,
                 from prize.h:1,
                 from prize.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
prize.cpp:21:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::array<int, 2>')
   21 |   mx = max(mx,qry(a[i]));
      |                        ^
In file included from /usr/include/c++/10/vector:60,
                 from prize.h:1,
                 from prize.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
prize.cpp:21:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::array<int, 2>')
   21 |   mx = max(mx,qry(a[i]));
      |                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from prize.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
prize.cpp:21:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |   mx = max(mx,qry(a[i]));
      |                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from prize.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
prize.cpp:21:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |   mx = max(mx,qry(a[i]));
      |                        ^
prize.cpp: In lambda function:
prize.cpp:32:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   32 |   ll m = l+r>>1;
      |          ~^~