# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
400312 | Pichon5 | Traffic (IOI10_traffic) | C++17 | 1168 ms | 186444 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>
#include "traffic.h"
#define pb push_back
#define vi vector<int>
#define ll long long
using namespace std;
const int tam=1e6;
vector<int> G[tam];
ll peso[tam];
ll tot[tam];//suma de todos sus hijos
ll dp[tam];//maximo de sus hijos
ll sum=0;
int ind=0;
ll mi=1e18;
void dfs(ll nodo, int p){
for(int i=0;i<G[nodo].size();i++){
int it=G[nodo][i];
if(it==p)continue;
dfs(it,nodo);
tot[nodo]+=tot[it];
dp[nodo]=max(dp[nodo],tot[it]);
}
ll aux=max(dp[nodo],sum-tot[nodo]);
if(aux<mi){
ind=nodo;
mi=aux;
}
}
int LocateCentre(int N, int pp[], int S[], int D[]) {
for(int i=0;i<N;i++){
peso[i]=pp[i];sum+=pp[i];tot[i]=peso[i];
}
for(int i=0;i<N-1;i++){
int a=S[i],b=D[i];
G[a].pb(b);G[b].pb(a);
}
dfs(0,-1);
return ind;
}
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... |