제출 #582905

#제출 시각아이디문제언어결과실행 시간메모리
582905sff_userTraffic (IOI10_traffic)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #include "traffic.h" #define pb push_back #define vi vector<int> using namespace std; vector<vi > adj; int sub[1000006]; int par[1000006]; void dfs(int u , int p, int pp[]){ sub[u] = pp[u]; par[u] = p; for(int v : adj[u]){ if(v== p) continue; dfs(v,u,pp); sub[u] += sub[v]; } } int LocateCentre(int n, int pp[] , int S[], int D[]) { adj.resize(n+1); for(int i = 0 ; i < n-1 ; i++){ adj[S[i]].pb(D[i]); adj[D[i]].pb(S[i]); } dfs(0,-1,pp); int a =1e9, b = 0; for(int i = 0 ; i < n ; i++){ for(int j : adj[i]){ if(j != par[i]){ b = max(b,sub[j]); continue; } b = max(b,sub[0]-sub[i]); } a = min(a,b); } return a; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...