Submission #426606

#TimeUsernameProblemLanguageResultExecution timeMemory
426606nots0fastTraffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define ld long double
#define MAX (int)(pow(10,6) + 10)
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9) + 7;

ll dp[MAX];
vector<ll> g[MAX];
ll val[MAX];
ll par[MAX];

void dfs(ll hd, ll pr){
	dp[hd] = val[hd];
	par[hd] = pr;
	for(auto& hr : g[hd]){
		if(pr == hr){
			continue;
		}
		dfs(hr, hd);
		dp[hd] += dp[hr];
	}
}

void deal(){
	ll n;
	cin>>n;
	ll tot = 0;
	fori(n){
		cin>>val[i];
		tot+=val[i];
	}
	fori(n-1){
		ll ai, bi;
		cin>>ai>>bi;
		g[ai].pb(bi);
		g[bi].pb(ai);
	}
	dfs(0, -1);
	ll mn = inf;
	ll lz = -1;
	fori(n){
		ll mx = tot - dp[i];
		for(auto& hr : g[i]){
			if(hr == par[i]){
				continue;
			}
			mx = max(mx, dp[hr]);
		}
		if(mx < mn){
			mn= mx;
			lz = i;
		}
	}
	cout<<lz;
}


int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}









Compilation message (stderr)

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