제출 #503246

#제출 시각아이디문제언어결과실행 시간메모리
503246Hi_Im_Not_Meo_MeoTraffic (IOI10_traffic)C++14
컴파일 에러
0 ms0 KiB
#include"bits/stdc++.h"
#define f(i,j,k) for(int i=j;i<=k;i++)
#define pb push_back

const int N = 1e6+6;
using namespace std;
int n, vt, ans = 2e9;
int a[N], b[N];
vector <int> adj[N];

void dfs(int u,int pre){
	b[u] = a[u];
	for(auto v: adj[u])
		if(v != pre){
			dfs(v,u);
			b[u] += b[v];
		}
}

void dff(int u,int pre,int val){
	int mx = val;
	for(auto v: adj[u])
		if(v != pre){
			dff(v,u,val+b[u]-b[v]);
			mx = max(mx,b[v]);
		}
	if(mx < ans){
		vt = u;
		ans = mx;
	}
}

main(){	
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	f(i,1,n) cin>>a[i];
	f(i,2,n){
		int u, v;
		cin>>u>>v;
		u++; v++;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs(1,0);	
	dff(1,0,0);
	cout<<vt-1;
}

컴파일 시 표준 에러 (stderr) 메시지

traffic.cpp:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   33 | main(){
      | ^~~~
/usr/bin/ld: /tmp/ccfhg8fK.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc1lYKxI.o:traffic.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccfhg8fK.o: in function `main':
grader.cpp:(.text.startup+0xe1): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status