# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
878962 | sabukatsire | Traffic (IOI10_traffic) | C++17 | 8 ms | 31068 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<bits/stdc++.h>
using namespace std;
#include "traffic.h"
vector<int> v[1000001];
int sz[1000001],ans = 200000000000,idx;
void dfs(int curr,int pp,int sum){
int mx = 0;
for(int j=0;j<v[curr].size();j++){
if(v[curr][j] == pp) continue;
dfs(v[curr][j],curr,sum);
sz[curr] += sz[v[curr][j]];
mx = max(sz[v[curr][j]],mx);
} mx = max(mx,sum-sz[curr]);
if(ans > mx){
ans = mx;
idx = curr;
}
}
int LocateCentre(int n,int p[1000001],int s[1000001],int d[1000001]){
int sum = 0;
for(int i=0;i<n;i++) v[i].clear();
for(int i=0;i<n;i++){
v[s[i]].push_back(d[i]);
v[d[i]].push_back(s[i]);
sz[i] = p[i]; sum += p[i];
}
dfs(0,0,sum);
return idx;
}
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... |