Submission #660249

#TimeUsernameProblemLanguageResultExecution timeMemory
660249QwertyPiTraffic (IOI10_traffic)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 11; int p[N], sz[N]; vector<int> G[N]; void dfs(int v, int par = -1){ for(auto i : G[v]){ if(i != par){ dfs(i, v); sz[v] += sz[i]; } } sz[v] += p[v]; } void centroid(int v, int par = -1){ for(auto i : G[v]){ if(i != par && sz[i] >= (sz[0] + 1) / 2){ centroid(i, v); return; } } cout << v << endl; return; } int main() { int n; cin >> n; for(int i = 0; i < n; i++){ cin >> p[i]; } for(int i = 0; i < n - 1; i++){ int u, v; cin >> u >> v; G[u].push_back(v); G[v].push_back(u); } dfs(0); centroid(0); }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccht6YYX.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccF7s8rU.o:traffic.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccht6YYX.o: in function `main':
grader.cpp:(.text.startup+0xe1): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status