Submission #420916

#TimeUsernameProblemLanguageResultExecution timeMemory
420916JooTraffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define int long long using namespace std; const int N = 1e6+10; int dp[N],sum[N],val[N],sumall; vector<int> vec[N]; void fisum(int u, int p){ sum[u] = val[u]; sumall += val[u]; for(int v : vec[u]){ if(v == p) continue; fisum(v, u); sum[u] += sum[v]; } } void solve(int u, int p){ int res = -1e18; for(int v : vec[u]){ if(v == p) continue; solve(v, u); dp[u] = min(dp[u], dp[v]); res = max(res, sum[v]); } res = max(res, sumall-sum[u]); dp[u] = min(dp[u], res); } int LocateCentre(int n, int P[], int E1[], int E2[]){ for(int i=0; i<n; i++){ val[i] = P[i]; dp[i] = 1e18; } for(int i=0; i<n-1; i++){ vec[E1[i]].emplace_back(E2[i]); vec[E2[i]].emplace_back(E1[i]); } fisum(0, 0); solve(0, 0); return dp[0]; } /*main(){ int n,P[N],S[N],D[N]; cin >> n; cout << "TEST"; for(int i=0; i<n; i++){ cin >> P[i]; } for(int i=0; i<n-1; i++){ cin >> S[i] >> D[i]; } cout << LocateCentre(n, P, S, D); }*/

Compilation message (stderr)

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