Submission #1147419

#TimeUsernameProblemLanguageResultExecution timeMemory
1147419aminjon__Race (IOI11_race)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define endl '\n' typedef unsigned int uint; typedef long long ll; typedef long double ld; typedef unsigned long long ull; using namespace std; // #include "race.h" int best_path(int N, int K, int H[][2], int L[]) { vector<vector<pair<ll,ll>>>rebr(N+1); for(int i = 0;i < N-1;i++){ rebr[H[i][0]].push_back({H[i][1],L[i]}); rebr[H[i][1]].push_back({H[i][0],L[i]}); } ll ans = LLONG_MAX; function<set<pair<ll,ll>>(ll,ll,ll,ll) > dfs; dfs = [&](ll x , ll p , ll sum , ll depth) { set< pair<ll,ll> > Suffix; Suffix.insert({sum , depth}); for(auto g: rebr[x]){ if(g.first==p)continue; set<pair<ll,ll>> govno = dfs(g , x , sum+g.second ,depth+1); if(Suffix.size() < govno.size()){ swap(govno, Suffix); } for(auto g: govno){ Suffix.insert(g); } } for(auto g: Suffix){ if(g.first == sum+K){ ans = min(g.second-depth ,ans); continue; } auto r = Suffix.upper_bound({sum+sum+K - g.first , 0}); if(r != Suffix.end() && (r->first) == sum+sum+K-g.first){ ans = min(ans , g.second+(r->second) - (depth*2) ); } } return Suffix; }; dfs(1 , 0 , 0 , 0); return (ans == LLONG_MAX ? -1 : ans); }

Compilation message (stderr)

race.cpp: In lambda function:
race.cpp:31:41: error: no match for call to '(std::function<std::set<std::pair<long long int, long long int> >(long long int, long long int, long long int, long long int)>) (std::pair<long long int, long long int>&, ll&, ll, ll)'
   31 |             set<pair<ll,ll>> govno = dfs(g , x , sum+g.second ,depth+1);
      |                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/functional:59,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from race.cpp:1:
/usr/include/c++/11/bits/std_function.h:586:7: note: candidate: '_Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = std::set<std::pair<long long int, long long int> >; _ArgTypes = {long long int, long long int, long long int, long long int}]'
  586 |       operator()(_ArgTypes... __args) const
      |       ^~~~~~~~
/usr/include/c++/11/bits/std_function.h:586:27: note:   no known conversion for argument 1 from 'std::pair<long long int, long long int>' to 'long long int'
  586 |       operator()(_ArgTypes... __args) const
      |                  ~~~~~~~~~^~~~~~~~~~