제출 #362312

#제출 시각아이디문제언어결과실행 시간메모리
362312saifuTraffic (IOI10_traffic)C++14
50 / 100
5060 ms30572 KiB
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful ----- #include "traffic.h" #include<bits/stdc++.h> using namespace std; #define endl "\n" #define mod 1000000007 #define inf (int)1e18 const int mxn = 1e6+10; vector<int> g[mxn]; int people[mxn]; int dp[mxn]; void dfs(int v, int p=-1){ dp[v] = people[v]; for(int u : g[v]){ if(u==p) continue; dfs(u,v); dp[v] += dp[u]; } } int LocateCentre (int n, int p[], int d[], int s[]){ for(int i=0;i<n;i++) people[i] = p[i]; for(int i=0;i<n-1;i++){ g[s[i]].push_back(d[i]); g[d[i]].push_back(s[i]); } int mn = inf,idx=-1; for(int i=0;i<n;i++){ for(int j=0;j<n;j++) dp[i] = 0; dfs(i); int mx = 0; for(int u : g[i]){ mx = max(mx,dp[u]); } if(mn>mx){ mn = mx; idx = i; } } return idx; } // int32_t main(){ // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // int n; cin >> n; // for(int i=0;i<n;i++) cin >> people[i]; // for(int i=0;i<n-1;i++){ // int u,v; cin >> u >> v; // g[v].push_back(u); // g[u].push_back(v); // } // return 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...