Submission #711920

#TimeUsernameProblemLanguageResultExecution timeMemory
711920Hoff22Race (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> #define N 200000 #define MAX 1000000000 #define E 0.00000001 #define MOD 1000000007 #define INF 0x3f3f3f3f #define INFll 0x3f3f3f3f3f3f3f3fll #define LEFT(x) (2 * x) #define RIGHT(x) (2 * x + 1) #define se second #define fi first using namespace std; typedef long long ll; vector<int> g[N+1]; map<pair<int,int>, ll> e; map<ll,int> d[N+1]; ll dist[N+1]; int sz[N+1]; int ans = -1; void prec(ll u, ll p){ dist[u] = dist[p] + e[{u,p}]; for(ll v : g[u]){ if(v == p) continue; prec(v, u); } } void solve(ll u, ll p, ll depth, ll k){ ll big = -1; sz[u] = 1; for(ll v : g[u]){ if(v == p) continue; solve(v, u, depth+1, k); sz[u] += sz[v]; if(big == -1 or sz[v] > sz[big]) big = v; } if(big == -1){ d[u][dist[u]] = depth; return; } swap(d[u], d[big]); d[u][dist[u]] = depth; for(ll v : g[u]){ if(v == p or v == big) continue; for(auto i : d[v]){ if(d[u].count(i.fi)){ d[u][i.fi] = min(d[u][i.fi], i.se); } else{ d[u][i.fi] = i.se; } ll want = k + 2 * dist[u] - i.fi; if(d[u].count(want)){ if(ans == -1) ans = (d[u][i.fi] - depth) + (d[u][want] - depth); else ans = min(ans, (d[u][i.fi] - depth) + (d[u][want] - depth)); } } } if(d[u].count(k + dist[u])){ if(ans == -1) ans = d[u][k + dist[u]] - depth; else ans = min(ans, d[u][k + dist[u]] - depth); } } int best_path(int n, int k, int (*h)[2], int* l){ ios_base::sync_with_stdio(false); cin.tie(NULL); for(ll i = 0; i <= n; i++){ g[i].clear(); dist[i] = 0; sz[i] = 0; d[i].clear(); } ans = -1; e.clear(); for(ll i = 0; i < n-1; i++){ ll u, v, w; u = h[i][0]; v = h[i][1]; w = l[i]; u++; v++; g[u].push_back(v); g[v].push_back(u); e[{u,v}] = w; e[{v,u}] = w; } prec(1,0); solve(1, 0, 0, k); return ans; }

Compilation message (stderr)

race.cpp: In function 'void solve(ll, ll, ll, ll)':
race.cpp:67:68: error: no matching function for call to 'min(int&, ll)'
   67 |     else ans = min(ans, (d[u][i.fi] - depth) + (d[u][want] - depth));
      |                                                                    ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from race.cpp:2:
/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:
race.cpp:67:68: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   67 |     else ans = min(ans, (d[u][i.fi] - depth) + (d[u][want] - depth));
      |                                                                    ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from race.cpp:2:
/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:
race.cpp:67:68: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   67 |     else ans = min(ans, (d[u][i.fi] - depth) + (d[u][want] - depth));
      |                                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from race.cpp:2:
/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:
race.cpp:67:68: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   67 |     else ans = min(ans, (d[u][i.fi] - depth) + (d[u][want] - depth));
      |                                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from race.cpp:2:
/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:
race.cpp:67:68: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   67 |     else ans = min(ans, (d[u][i.fi] - depth) + (d[u][want] - depth));
      |                                                                    ^
race.cpp:75:49: error: no matching function for call to 'min(int&, ll)'
   75 |   else  ans = min(ans, d[u][k + dist[u]] - depth);
      |                                                 ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from race.cpp:2:
/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:
race.cpp:75:49: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   75 |   else  ans = min(ans, d[u][k + dist[u]] - depth);
      |                                                 ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from race.cpp:2:
/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:
race.cpp:75:49: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   75 |   else  ans = min(ans, d[u][k + dist[u]] - depth);
      |                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from race.cpp:2:
/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:
race.cpp:75:49: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   75 |   else  ans = min(ans, d[u][k + dist[u]] - depth);
      |                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from race.cpp:2:
/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:
race.cpp:75:49: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   75 |   else  ans = min(ans, d[u][k + dist[u]] - depth);
      |                                                 ^