# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
360251 | 2021-01-28T00:08:29 Z | sumit_kk10 | Traffic (IOI10_traffic) | C++14 | 2 ms | 2668 KB |
#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]; long long 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]); } long long int mn = LLONG_MAX, res; for(int i = 0; i < n; ++i){ dfs(i, p); long long int mx = p[i]; for(auto k : graph[i]) mx = max(mx, dis[k]); if(mn > mx){ mn = mx; res = i; } // cout << mx << endl; for(int j = 0; j < n; ++j) vis[j] = 0; } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2668 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2668 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2668 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 2668 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |