Submission #528240

#TimeUsernameProblemLanguageResultExecution timeMemory
528240Leo121Traffic (IOI10_traffic)C++14
0 / 100
15 ms23840 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 visitado[lim]; ll mayor = LLONG_MAX, res = 0; ll pesosub[lim]; int padre[lim]; ll dfs(int u){ pesosub[u] = (ll) pesos[u]; for(int v : graph[u]){ if(!visitado[v]){ padre[v] = u; visitado[v] = 1; pesosub[u] += dfs(v); } } return pesosub[u]; } int LocateCentre(int N, int pp[], int S[], int D[]) { ll pesototal = 0; forn(i, 0, N - 1){ pesos[i] = pp[i]; pesototal += (ll) pp[i]; visitado[i] = 0; pesosub[i] = 0; } forn(i, 0, N - 2){ graph[S[i]].pb(D[i]); graph[D[i]].pb(S[i]); } visitado[0] = 1; padre[0] = 0; dfs(0); ll minimo = INT_MAX, aux = 0; int res = 0; for(int i : graph[0]){ aux = max(aux, pesosub[i]); } minimo = aux; forn(i, 1, N - 1){ aux = 0; for(int j : graph[i]){ if(padre[j] == i){ aux = max(aux, pesosub[j]); } } aux = max(aux, pesototal - pesosub[i]); if(mayor >= aux){ mayor = aux; res = i; } } return res; }

Compilation message (stderr)

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:42:8: warning: variable 'minimo' set but not used [-Wunused-but-set-variable]
   42 |     ll minimo = INT_MAX, aux = 0;
      |        ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...