제출 #805289

#제출 시각아이디문제언어결과실행 시간메모리
805289QwertyPiTraffic (IOI10_traffic)C++14
0 / 100
11 ms23764 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 11; int p[N], sz[N]; vector<int> G[N]; void dfs(int v, int par = -1){ for(auto i : G[v]){ if(i != par){ dfs(i, v); sz[v] += sz[i]; } } sz[v] += p[v]; } int centroid(int v, int par = -1){ for(auto i : G[v]){ if(i != par && sz[i] >= (sz[0] + 1) / 2){ return centroid(i, v); } } return v; } int LocateCentre(int N, int pp[], int S[], int D[]) { for(int i = 0; i < N - 1; i++){ G[S[i]].push_back(D[i]); G[D[i]].push_back(S[i]); } dfs(0); return centroid(0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...