Submission #897183

#TimeUsernameProblemLanguageResultExecution timeMemory
897183IwanttobreakfreeTraffic (IOI10_traffic)C++14
50 / 100
5073 ms14940 KiB
#include <bits/stdc++.h> using namespace std; int cur_nodo, max_ans; long long dfs(int nodoActual, vector<vector<int>>& lista, int par, int P[]) { long long ans = 0; int maxi = 0; for (int vecino: lista[nodoActual]) { if (vecino == par) continue; int cur = dfs(vecino, lista, nodoActual, P); ans += cur; maxi = max(maxi, cur); } if (cur_nodo == nodoActual) max_ans = maxi; return ans+P[nodoActual]; } int LocateCentre (int N, int P[], int S[], int D[]) { vector<vector<int>> g(N, vector<int>()); for (int i = 0; i < N-1; ++i) { g[S[i]].push_back(D[i]); g[D[i]].push_back(S[i]); } long long maxi = 2e18+1, ans = -1; for (int i = 0; i < N; ++i) { cur_nodo = i; long long cur = dfs(i, g, i, P); if (max_ans < maxi) { maxi = max_ans; ans = i; } } return ans; }

Compilation message (stderr)

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:28:19: warning: unused variable 'cur' [-Wunused-variable]
   28 |         long long cur = dfs(i, g, i, P);
      |                   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...