Submission #554152

#TimeUsernameProblemLanguageResultExecution timeMemory
554152AlmaTraffic (IOI10_traffic)C++17
0 / 100
1 ms312 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; // void re_assign (int N, int idx) { // visited.assign(N, false); // visited[idx] = true; // } 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]; } 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]); } vector<pair<ll, int>> maximums (N); ll maxCongestion = -1; for (int city = 0; city < N; city++) { visited.assign(N, false); // re_assign(N, city); // for (int road: graph[city]) { ll congestion = traffic(city); maxCongestion = max(maxCongestion, congestion); // } maximums[city].first = maxCongestion; maximums[city].second = city; } sort (maximums.begin(), maximums.end()); pair<ll, int> arenaCity = maximums[0]; return arenaCity.second; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...