Submission #499558

#TimeUsernameProblemLanguageResultExecution timeMemory
499558iwantinTraffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define M_PI 3.14159265358979323846 #define pb push_back #define fs first #define sc second typedef long long ll; typedef long double ld; const ll mod = 1e9 + 7; const ll maxn = 1e6 + 1; const ll inf = LLONG_MAX; const ll minf = LLONG_MIN; vector <ll> cost(maxn), dist(maxn), children(maxn), ans(maxn); vector <vector <ll> > g(maxn); vector <bool> used(maxn); ll n; ll findChildren(ll v){ used[v] = true; children[v] = 1; for(auto i: g[v]) if(!used[i]) children[v] += findChildren(i); return children[v]; } ll findDist(ll v){ used[v] = true; ll isZero = !(v == 0), num = 0; ans[0] += cost[v] * children[v] * isZero; for(auto i: g[v]) if(!used[i]) num += findDist(i); dist[v] = num + cost[v] * children[v] * isZero; return dist[v]; } void findAns(ll v, ll parent = -1){ used[v] = true; if(parent != -1){ ans[v] = cost[parent] * (n - children[parent] + 1) + ans[parent]; ans[v] -= cost[v] * (children[v]); } for(auto i: g[v]) if(!used[i]) findAns(i, v); } int main(){ ios_base :: sync_with_stdio(false); cin.tie(NULL); cin>>n; for(ll k = 0; k < n; k++) cin>>cost[k]; for(ll k = 0; k < n - 1; k++){ ll a, b; cin>>a>>b; g[a].pb(b); g[b].pb(a); } findChildren(0); for(ll k = 0; k < n; k++) used[k] = false; findDist(0); for(ll k = 0; k < n; k++) used[k] = false; findAns(0); ll mn = LLONG_MAX, ansk = 0; for(ll k = 0; k < n; k++){ if(ans[k] < mn){ mn = ans[k]; ansk = k; } } cout<<ansk; return 0; }

Compilation message (stderr)

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