Submission #895176

#TimeUsernameProblemLanguageResultExecution timeMemory
895176IrateTraffic (IOI10_traffic)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; vector<vector<int>>G; vector<long long>sz, val, res; int n; long long sum = 0; void dfs(int node, int par){ sz[node] = val[node]; for(int &v : G[node]){ if(v != par){ dfs(v, node); sz[node] += sz[v]; } } long long sub_sum = 0; for(int &v : G[node]){ res[node] = max(res[node], sz[v]); sub_sum += sz[v]; } res[node] = max(res[node], sum - sub_sum); } int LocateCentre(int N, vector<int>&P, vector<int>&S, vector<int>&D){ int n = N; G.resize(n); sz.resize(n); res.resize(n); val.resize(n); for(int i = 0;i < n;++i){ val[i] = P[i]; sum += P[i]; } for(int i = 0;i < n - 1;++i){ G[S[i]].push_back(D[i]); G[D[i]].push_back(S[i]); } dfs(0, 0); long long mn = 1e18, id = -1; for(int i = 0;i < n;++i){ if(res[i] < mn){ mn = res[i]; id = i; } } return id; } // int main(){ // ios_base::sync_with_stdio(0); // cin.tie(0); // int n; // cin >> n; // vector<int>P(n), S(n - 1), D(n - 1); // 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/ccIQDb6H.o: in function `main':
grader.cpp:(.text.startup+0xe1): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status