제출 #528197

#제출 시각아이디문제언어결과실행 시간메모리
528197Leo121Traffic (IOI10_traffic)C++14
0 / 100
15 ms23804 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...