답안 #298472

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
298472 2020-09-13T00:34:00 Z Hemimor Traffic (IOI10_traffic) C++14
0 / 100
1 ms 384 KB
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,res=2000000001,sum=0;
vvi g;
vi a,s;

void dfs(int v,int p){
	s[v]++;
	int tmp=0;
	for(auto u:g[v]) if(u!=p){
		dfs(u,v);
		s[v]+=s[u];
		tmp=max(tmp,s[u]);
	}
	tmp=max(tmp,sum-s[v]);
	res=min(res,tmp);
}

int LocateCentre(int N,int P[],int S[],int D[]){
	n=N;
	g=vvi(n);
	a=s=vi(n);
	for(int i=0;i<n;i++){
		a[i]=P[i];
		sum+=a[i];
	}
	for(int i=0;i<n-1;i++){
		int u=S[i],v=D[i];
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0,-1);
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -