답안 #271908

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
271908 2020-08-18T07:58:28 Z TMJN Traffic (IOI10_traffic) C++17
컴파일 오류
0 ms 0 KB
#include "traffic.h"
#include <bits/stdc++.h>
using namespace std;

vector<int>v[1000000];
long long c[1000000],m[1000000];

void dfs(int x,int from){
	for(int i:v){
		if(i==from)continue;
		dfs(i,x);
		c[x]+=c[i];
	}
}

int LocateCentre(int N, int pp[], int S[], int D[]) {
	for(int i=0;i<N-1;i++){
		v[S[i]].push_back(D[i]);
		v[D[i]].push_back(S[i]);
	}
	for(int i=0;i<N;i++){
		c[i]=pp[i];
	}
	dfs(0,0);
	for(int i=0;i<N-1;i++){
		m[S[i]]=max(m[S[i]],abs(c[S[i]]-c[D[i]]));
		m[D[i]]=max(m[D[i]],abs(c[S[i]]-c[D[i]]));
	}
	pair<ll,int>res={0xE869120E869120,-1};
	for(int i=0;i<N;i++){
		res=min(res,{m[i],i});
	}
	return res.second;
}

Compilation message

traffic.cpp: In function 'void dfs(int, int)':
traffic.cpp:9:12: error: cannot convert 'std::vector<int>' to 'int' in initialization
    9 |  for(int i:v){
      |            ^
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:29:7: error: 'll' was not declared in this scope
   29 |  pair<ll,int>res={0xE869120E869120,-1};
      |       ^~
traffic.cpp:29:13: error: template argument 1 is invalid
   29 |  pair<ll,int>res={0xE869120E869120,-1};
      |             ^
traffic.cpp:29:14: error: scalar object 'res' requires one element in initializer
   29 |  pair<ll,int>res={0xE869120E869120,-1};
      |              ^~~