Submission #991077

#TimeUsernameProblemLanguageResultExecution timeMemory
991077borisAngelovTraffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1000005; const long long inf = (1LL << 60); int n; int a[maxn]; vector<int> g[maxn]; long long ans[maxn]; long long subtreeSum[maxn]; long long down[maxn]; void dfs(int node, int par, int dep) { down[node] = 0; subtreeSum[node] = a[node]; for (int i = 0; i < g[node].size(); ++i) { int to = g[node][i]; if (to != par) { dfs(to, node, dep + 1); subtreeSum[node] += subtreeSum[to]; down[node] = max(down[node], subtreeSum[to]); } } } long long LocateCentre(int N, int pp[], int S[], int D[]) { n = N; for (int i = 1; i <= n; ++i) { a[i] = pp[i]; } for (int i = 1; i <= n - 1; ++i) { int x = S[i - 1]; int y = D[i - 1]; ++x; ++y; g[x].push_back(y); g[y].push_back(x); } long long ans = inf; for (int i = 1; i <= n; ++i) { dfs(i, -1, 0); ans = min(ans, down[i]); } return ans; }

Compilation message (stderr)

traffic.cpp: In function 'void dfs(int, int, int)':
traffic.cpp:23:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for (int i = 0; i < g[node].size(); ++i)
      |                     ~~^~~~~~~~~~~~~~~~
traffic.cpp: At global scope:
traffic.cpp:36:11: error: ambiguating new declaration of 'long long int LocateCentre(int, int*, int*, int*)'
   36 | long long LocateCentre(int N, int pp[], int S[], int D[])
      |           ^~~~~~~~~~~~
In file included from traffic.cpp:1:
traffic.h:1:5: note: old declaration 'int LocateCentre(int, int*, int*, int*)'
    1 | int LocateCentre(int N, int P[], int S[], int D[]);
      |     ^~~~~~~~~~~~