Submission #316342

#TimeUsernameProblemLanguageResultExecution timeMemory
316342vishnu_sujithTraffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; #ifdef DEBUG #define LOG(...) cerr << "[" << #__VA_ARGS__ << "]: " << repr(__VA_ARGS__) << endl; #define MSG(args) cerr << args << "\n"; #define debug(x) x #else #define LOG(...) #define MSG(args) #define debug(x) #endif #define mp make_pair #define pb push_back #define sz(x) (int)((x).size()) #define ms(x, v) memset((x), v, sizeof(x)) #define all(x) (x).begin(), (x).end() #define REP(x, n) for(int x = 0; x < n; x++) #define REPV(x, v, n) for(int x = v; x < n; x++) #define REVE(x, n) for(int x = n; x >= 0; x--) using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vii = vector<pii>; using vvi = vector<vi>; vi adj[1000010]; ll tot_fans = 0, size[1000010], cnt[1000010]; void dfs(int u, int parent, int P[]) { for(int v : adj[u]) if(v != parent) { dfs(v, u, P); size[u] += size[v]; cnt[u] = max(cnt[u], size[v]); } cnt[u] = max(cnt[u], tot_fans - size[u] - P[u]); size[u] += P[u]; } int LocateCentre(int N, int P[], int S[], int D[]) { tot_fans = accumulate(P, P + N, 0LL); REP(i, N - 1) adj[S[i]].pb(D[i]), adj[D[i]].pb(S[i]); dfs(0, -1, P); return min_element(cnt, cnt + N) - cnt; }

Compilation message (stderr)

traffic.cpp: In function 'void dfs(int, int, int*)':
traffic.cpp:41:9: error: reference to 'size' is ambiguous
   41 |         size[u] += size[v];
      |         ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from traffic.cpp:2:
/usr/include/c++/9/bits/range_access.h:252:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  252 |     size(const _Tp (&/*__array*/)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:242:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  242 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
traffic.cpp:34:18: note:                 'll size [1000010]'
   34 | ll tot_fans = 0, size[1000010], cnt[1000010];
      |                  ^~~~
traffic.cpp:41:20: error: reference to 'size' is ambiguous
   41 |         size[u] += size[v];
      |                    ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from traffic.cpp:2:
/usr/include/c++/9/bits/range_access.h:252:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  252 |     size(const _Tp (&/*__array*/)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:242:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  242 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
traffic.cpp:34:18: note:                 'll size [1000010]'
   34 | ll tot_fans = 0, size[1000010], cnt[1000010];
      |                  ^~~~
traffic.cpp:42:30: error: reference to 'size' is ambiguous
   42 |         cnt[u] = max(cnt[u], size[v]);
      |                              ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from traffic.cpp:2:
/usr/include/c++/9/bits/range_access.h:252:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  252 |     size(const _Tp (&/*__array*/)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:242:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  242 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
traffic.cpp:34:18: note:                 'll size [1000010]'
   34 | ll tot_fans = 0, size[1000010], cnt[1000010];
      |                  ^~~~
traffic.cpp:44:37: error: reference to 'size' is ambiguous
   44 |     cnt[u] = max(cnt[u], tot_fans - size[u] - P[u]);
      |                                     ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from traffic.cpp:2:
/usr/include/c++/9/bits/range_access.h:252:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  252 |     size(const _Tp (&/*__array*/)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:242:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  242 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
traffic.cpp:34:18: note:                 'll size [1000010]'
   34 | ll tot_fans = 0, size[1000010], cnt[1000010];
      |                  ^~~~
traffic.cpp:45:5: error: reference to 'size' is ambiguous
   45 |     size[u] += P[u];
      |     ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from traffic.cpp:2:
/usr/include/c++/9/bits/range_access.h:252:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  252 |     size(const _Tp (&/*__array*/)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:242:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  242 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
traffic.cpp:34:18: note:                 'll size [1000010]'
   34 | ll tot_fans = 0, size[1000010], cnt[1000010];
      |                  ^~~~