Submission #554170

#TimeUsernameProblemLanguageResultExecution timeMemory
554170AlmaTraffic (IOI10_traffic)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> // #include "traffic.h" using namespace std; typedef long long int ll; vector<vector<int>> graph; vector<ll> cost; vector<bool> visited; vector<ll> DP; int arenaCity; ll traffic (int city) { if (DP[city] != -1) return DP[city]; DP[city] = cost[city]; visited[city] = true; for (int road: graph[city]) { if (!visited[road]) DP[city] += traffic(road); } return DP[city]; } void untraffic (int city) { int bestCity = city; ll bestDiff = 1e9, maxCongestion = DP[city]; for (int road: graph[city]) { if (DP[road] < maxCongestion) continue; ll diff = maxCongestion - DP[road]; if (diff < bestDiff) { bestCity = road; bestDiff = diff; } } if (bestCity != city) { DP[city] -= DP[bestCity]; DP[bestCity] = maxCongestion; arenaCity = bestCity; } } int LocateCentre(int N, int pp[], int S[], int D[]) { graph.assign(N, vector<int>()); cost.clear(); DP.assign(N, -1); for (int i = 0; i < N; i++) { graph[S[i]].push_back(D[i]); graph[D[i]].push_back(S[i]); cost.push_back(pp[i]); } visited.assign(N, false); ll congestion = traffic(0); arenaCity = 0; untraffic(0); return arenaCity; }

Compilation message (stderr)

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:58:8: warning: unused variable 'congestion' [-Wunused-variable]
   58 |     ll congestion = traffic(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...