# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
671958 | sudheerays123 | Traffic (IOI10_traffic) | C++17 | 1 ms | 344 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "traffic.h"
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll int
const ll N = 1000+5 , INF = 1e9 , MOD = 1e9+7;
vector<ll> adj[N+5];
vector<ll> sub(N+5);
ll dfs(ll s , ll par , int p[]){
ll ans = -INF;
for(auto u : adj[s]){
if(u == par) continue;
dfs(u,s,p);
ans = max(ans,sub[u]+p[u]);
sub[s] += sub[u]+p[u];
}
return ans;
}
int LocateCentre(int n, int p[], int S[], int D[]){
for(ll i = 0; i < n-1; i++){
adj[S[i]].push_back(D[i]);
adj[D[i]].push_back(S[i]);
}
ll ans = INF , city;
for(ll i = 0; i < n; i++){
for(ll j = 0; j < n; j++) sub[j] = 0;
ll x = dfs(i,0,p);
if(x < ans){
ans = x;
city = i;
}
}
return city;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |