Submission #1015731

#TimeUsernameProblemLanguageResultExecution timeMemory
1015731AriadnaTraffic (IOI10_traffic)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "traffic.h" #define pb push_back #define ll long long using namespace std; vector<vector<int>> adj; vector<ll> sum; ll min_traffic, centre, total = 0; int dfs(int u, int p, vector<int>& P) { sum[u] = P[u]; ll traffic = 0; for (int v: adj[u]) { if (v == p) continue; sum[u] += dfs(v, u, P); traffic = max(traffic, sum[v]); } traffic = max(traffic, total-sum[u]); if (traffic < min_traffic) { min_traffic = traffic; centre = u; } return sum[u]; } int LocateCentre(int N, vector<int> P, vector<int> S, vector<int> D) { adj = vector<vector<int>>(N); sum = vector<ll>(N); for (int i = 0; i < N-1; ++i) { adj[S[i]].pb(D[i]); adj[D[i]].pb(S[i]); } for (int i = 0; i < N; ++i) total += P[i]; min_traffic = 1e18, centre = -1; dfs(0, 0, P); return centre; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccLS7Pgz.o: in function `main':
grader.cpp:(.text.startup+0xe1): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status