제출 #360247

#제출 시각아이디문제언어결과실행 시간메모리
360247sumit_kk10Traffic (IOI10_traffic)C++14
0 / 100
2 ms2688 KiB
#include "traffic.h" #include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL) using namespace std; const int N = 100000 + 5; const int MOD = 1e9 + 7; vector<int> graph[N]; int dis[N]; bool vis[N]; void dfs(int source, int p[]){ vis[source] = 1; dis[source] = p[source]; for(auto k : graph[source]){ if(!vis[k]) { dfs(k, p); dis[source] += dis[k]; } } } int LocateCentre(int n, int p[], int S[], int D[]){ for(int i = 0; i < n - 1; ++i){ graph[S[i]].push_back(D[i]); graph[D[i]].push_back(S[i]); } int mn = INT_MAX; for(int i = 0; i < n; ++i){ dfs(i, p); int mx = 0; for(auto k : graph[i]) mx = max(mx, dis[k]); mn = min(mn, mx); for(int j = 0; j < n; ++j) vis[j] = 0; } return mn; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...