# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1049611 | LittleOrange | The Big Prize (IOI17_prize) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 = 0;
vector<ll> a(n);
iota(a.begin(),a.end(),0);
shuffle(a.begin(),a.end(),mt);*/
ll ans = -1;
function<void(ll,ll)> dfs;
dfs = [&](ll l, ll r,ll dl, ll dr){
if (ans != -1) return;
if (l == r){
ans = l;
return;
}
ll m = l+r>>1;
auto o = qry(m);
if (o[0]+o[1]==0) {
ans = m;
return;
}
if (o[0]-dl>0){
dfs(l,m-1,dl,dr+o[1]);
}
if(o[1]-dr>0){
dfs(m+1,r,dl+o[0],dr);
}
};
dfs(0,n-1,0,0);
return ans;
}
Compilation message (stderr)
prize.cpp: In lambda function: prize.cpp:28:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses] 28 | ll m = l+r>>1; | ~^~ prize.cpp:35:24: error: no match for call to '(std::function<void(int, int)>) (ll&, ll, ll&, ll)' 35 | dfs(l,m-1,dl,dr+o[1]); | ^ In file included from /usr/include/c++/10/functional:59, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from prize.cpp:2: /usr/include/c++/10/bits/std_function.h:617:5: note: candidate: '_Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = void; _ArgTypes = {int, int}]' 617 | function<_Res(_ArgTypes...)>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/bits/std_function.h:617:5: note: candidate expects 2 arguments, 4 provided prize.cpp:38:24: error: no match for call to '(std::function<void(int, int)>) (ll, ll&, ll, ll&)' 38 | dfs(m+1,r,dl+o[0],dr); | ^ In file included from /usr/include/c++/10/functional:59, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from prize.cpp:2: /usr/include/c++/10/bits/std_function.h:617:5: note: candidate: '_Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = void; _ArgTypes = {int, int}]' 617 | function<_Res(_ArgTypes...)>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/bits/std_function.h:617:5: note: candidate expects 2 arguments, 4 provided prize.cpp: In function 'int find_best(int)': prize.cpp:40:2: error: no match for 'operator=' (operand types are 'std::function<void(int, int)>' and 'find_best(int)::<lambda(ll, ll, ll, ll)>') 40 | }; | ^ In file included from /usr/include/c++/10/functional:59, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from prize.cpp:2: /usr/include/c++/10/bits/std_function.h:396:7: note: candidate: 'std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(const std::function<_Res(_ArgTypes ...)>&) [with _Res = void; _ArgTypes = {int, int}]' 396 | operator=(const function& __x) | ^~~~~~~~ /usr/include/c++/10/bits/std_function.h:396:33: note: no known conversion for argument 1 from 'find_best(int)::<lambda(ll, ll, ll, ll)>' to 'const std::function<void(int, int)>&' 396 | operator=(const function& __x) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/std_function.h:414:7: note: candidate: 'std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(std::function<_Res(_ArgTypes ...)>&&) [with _Res = void; _ArgTypes = {int, int}]' 414 | operator=(function&& __x) noexcept | ^~~~~~~~ /usr/include/c++/10/bits/std_function.h:414:28: note: no known conversion for argument 1 from 'find_best(int)::<lambda(ll, ll, ll, ll)>' to 'std::function<void(int, int)>&&' 414 | operator=(function&& __x) noexcept | ~~~~~~~~~~~^~~ /usr/include/c++/10/bits/std_function.h:428:7: note: candidate: 'std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(std::nullptr_t) [with _Res = void; _ArgTypes = {int, int}; std::nullptr_t = std::nullptr_t]' 428 | operator=(nullptr_t) noexcept | ^~~~~~~~ /usr/include/c++/10/bits/std_function.h:428:17: note: no known conversion for argument 1 from 'find_best(int)::<lambda(ll, ll, ll, ll)>' to 'std::nullptr_t' 428 | operator=(nullptr_t) noexcept | ^~~~~~~~~ /usr/include/c++/10/bits/std_function.h:457:2: note: candidate: 'template<class _Functor> std::function<_Res(_ArgTypes ...)>::_Requires<std::function<_Res(_ArgTypes ...)>::_Callable<typename std::decay<_Functor>::type>, std::function<_Res(_ArgTypes ...)>&> std::function<_Res(_ArgTypes ...)>::operator=(_Functor&&) [with _Functor = _Functor; _Res = void; _ArgTypes = {int, int}]' 457 | operator=(_Functor&& __f) | ^~~~~~~~ /usr/include/c++/10/bits/std_function.h:457:2: note: template argument deduction/substitution failed: /usr/include/c++/10/bits/std_function.h: In substitution of 'template<class _Res, class ... _ArgTypes> template<class _Cond, class _Tp> using _Requires = typename std::enable_if<_Cond::value, _Tp>::type [with _Cond = std::function<void(int, int)>::_Callable<find_best(int)::<lambda(ll, ll, ll, ll)>, std::__invoke_result<find_best(int)::<lambda(ll, ll, ll, ll)>&, int, int> >; _Tp = std::function<void(int, int)>&; _Res = void; _ArgTypes = {int, int}]': /usr/include/c++/10/bits/std_function.h:457:2: required by substitution of 'template<class _Functor> std::function<void(int, int)>::_Requires<std::function<void(int, int)>::_Callable<typename std::decay<_Tp>::type, std::__invoke_result<typename std::decay<_Tp>::type&, int, int> >, std::function<void(int, int)>&> std::function<void(int, int)>::operator=<_Functor>(_Functor&&) [with _Functor = find_best(int)::<lambda(ll, ll, ll, ll)>]' prize.cpp:40:2: required from here /usr/include/c++/10/bits/std_function.h:319:8: error: no type named 'type' in 'struct std::enable_if<false, std::function<void(int, int)>&>' 319 | using _Requires = typename enable_if<_Cond::value, _Tp>::type; | ^~~~~~~~~ /usr/include/c++/10/bits/std_function.h:466:2: note: candidate: 'template<class _Functor> std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(std::reference_wrapper<_Functor>) [with _Functor = _Functor; _Res = void; _ArgTypes = {int, int}]' 466 | operator=(reference_wrapper<_Functor> __f) noexcept | ^~~~~~~~ /usr/include/c++/10/bits/std_function.h:466:2: note: template argument deduction/substitution failed: prize.cpp:40:2: note: 'find_best(int)::<lambda(ll, ll, ll, ll)>' is not derived from 'std::reference_wrapper<_Tp>' 40 | }; | ^ prize.cpp:41:15: error: no match for call to '(std::function<void(int, int)>) (int, int, int, int)' 41 | dfs(0,n-1,0,0); | ^ In file included from /usr/include/c++/10/functional:59, from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/10/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from prize.cpp:2: /usr/include/c++/10/bits/std_function.h:617:5: note: candidate: '_Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = void; _ArgTypes = {int, int}]' 617 | function<_Res(_ArgTypes...)>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/bits/std_function.h:617:5: note: candidate expects 2 arguments, 4 provided