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>
#define forn(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int lim = 1e6;
vi graph[lim];
int pesos[lim];
bool visitados[lim];
ll mayor = LLONG_MAX, res = 0;
ll trafico(int u){
ll suma = 0;
for(int v : graph[u]){
if(!visitados[v]){
visitados[v] = 1;
suma += trafico(v);
}
}
return suma + (ll) pesos[u];
}
int LocateCentre(int N, int pp[], int S[], int D[]) {
forn(i, 0, N - 1){
pesos[i] = pp[i];
}
forn(i, 0, N - 2){
graph[S[i]].pb(D[i]);
graph[D[i]].pb(S[i]);
}
ll aux;
forn(i, 0, N - 1){
forn(j, 0, N - 1){
visitados[j] = 0;
}
visitados[i] = 1;
aux = LLONG_MIN;
for(int j : graph[i]){
aux = max(aux, trafico(j));
}
if(mayor >= aux){
mayor = aux;
res = i;
}
}
return res;
}
# | 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... |