Submission #296414

#TimeUsernameProblemLanguageResultExecution timeMemory
296414moratoTraffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; vector<int> adj[maxn]; int p[maxn], h[maxn], sub[maxn], tot; int64_t dfs(int v, int _p = -1) { sub[v] = p[v]; for (int u : adj[v]) if (u != _p) { int64_t wgt = dfs(u, v); sub[v] += wgt; h[v] = max(h[v], wgt); } return sub[v]; } int LocateCentre(int N, int P[], int S[], int D[]) { for (int i = 0; i < N; i++) { p[i] = P[i]; } for (int i = 0; i < N; i++) { adj[S[i]].push_back(D[i]); adj[D[i]].push_back(S[i]); } dfs(0); int ans = 0; int64_t heavy = sub[0] - p[0]; for (int i = 1; i < N; i++) { h[i] = max(h[i], sub[0] - sub[i]); if (h[i] < heavy) { heavy = h[i]; ans = i; } } return ans; }

Compilation message (stderr)

traffic.cpp: In function 'int64_t dfs(int, int)':
traffic.cpp:14:25: error: no matching function for call to 'max(int&, int64_t&)'
   14 |     h[v] = max(h[v], wgt);
      |                         ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from traffic.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
traffic.cpp:14:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'int64_t' {aka 'long int'})
   14 |     h[v] = max(h[v], wgt);
      |                         ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from traffic.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
traffic.cpp:14:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'int64_t' {aka 'long int'})
   14 |     h[v] = max(h[v], wgt);
      |                         ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from traffic.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
traffic.cpp:14:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   14 |     h[v] = max(h[v], wgt);
      |                         ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from traffic.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
traffic.cpp:14:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   14 |     h[v] = max(h[v], wgt);
      |                         ^