제출 #730771

#제출 시각아이디문제언어결과실행 시간메모리
730771Jarif_RahmanTraffic (IOI10_traffic)C++17
100 / 100
891 ms170740 KiB
#include "traffic.h" #include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int n, sum = 0; vector<vector<int>> tree; vector<int> P, PP; int mn = 2e9+1, ans = -1; void dfs(int nd, int ss){ int mx = 0, up = sum-P[nd]; for(int x: tree[nd]) if(x != ss) dfs(x, nd), PP[nd]+=PP[x], mx = max(mx, PP[x]), up-=PP[x]; mx = max(mx, up); if(mx < mn) mn = mx, ans = nd; } int LocateCentre(int _n, int _P[], int U[], int V[]){ swap(n, _n); tree.resize(n); P.resize(n); for(int i = 0; i < n; i++) P[i] = _P[i]; PP = P; for(int i = 0; i < n-1; i++){ tree[U[i]].pb(V[i]); tree[V[i]].pb(U[i]); } for(int x: P) sum+=x; dfs(0, -1); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...