제출 #676320

#제출 시각아이디문제언어결과실행 시간메모리
676320stevancvTraffic (IOI10_traffic)C++14
0 / 100
15 ms23808 KiB
#include <bits/stdc++.h> #include "traffic.h" #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; const int N = 1e6 + 2; const ll linf = 1e18; vector<int> g[N]; int sz[N]; void Dfs(int s, int e) { for (int u : g[s]) { if (u == e) continue; Dfs(u, s); sz[s] += sz[u]; } } int Dfs1(int s, int e, int o) { for (int u : g[s]) { if (u == e) continue; if (2 * sz[u] > o) return Dfs1(u, s, o); } return s; } int LocateCentre(int n, int p[], int u[], int v[]) { for (int i = 0; i < n - 1; i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } for (int i = 0; i < n; i++) sz[i] = p[i]; Dfs(0, -1); return Dfs1(0, -1, sz[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...