Submission #231891

# Submission time Handle Problem Language Result Execution time Memory
231891 2020-05-15T08:58:12 Z sahil_k Traffic (IOI10_traffic) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
using namespace std;
int n;
int cnt[1000100];
vector<int> adj[1000100];
long long size[1000100];
void dfs1 (int x, int p) {
	size[x] = cnt[x];
	for (auto i: adj[x]) {
		if (i != p) {
			dfs1(i, x);
			size[x] += size[i];
		}
	}
}
long long ot = 1e14, oi;
void dfs2 (int x, int p, int u) {
	long long ans = u;
	for (auto i: adj[x]) {
		if (i != p) {
			ans = max(ans, size[i]);
			dfs2(i, x, u+size[x]-size[i]);
		}
	}
	if (ans < ot) {
		ot = ans;
		oi = x;
	}
}
int main () {
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> cnt[i];
	}
	int ai, bi;
	for (int i=0; i<n-1; i++) {
		cin >> ai >> bi;
		adj[ai].push_back(bi);
		adj[bi].push_back(ai);
	}
	dfs1(0, 0);
	dfs2(0, 0, 0);
	cout << oi << endl;
}

Compilation message

/tmp/cclplBNv.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccSlDaqH.o:traffic.cpp:(.text.startup+0x0): first defined here
/tmp/cclplBNv.o: In function `main':
grader.cpp:(.text.startup+0xb1): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status