Submission #995988

#TimeUsernameProblemLanguageResultExecution timeMemory
99598854skyxenonCrocodile's Underground City (IOI11_crocodile)C++17
100 / 100
1833 ms125976 KiB
// https://oj.uz/problem/view/IOI11_crocodile /** Needed for linking!!! */ #include "crocodile.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define INF (ll)1e18 int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { vector<map<int, int>> graph(N); vector<bool> is_exit(N); vector<set<int>> visited(N); for (int i = 0; i < M; i++) { graph[R[i][0]][R[i][1]] = graph[R[i][1]][R[i][0]] = L[i]; } for (int i = 0; i < K; i++) { is_exit[P[i]] = true; } // Run Dijkstra's vector<vector<ll>> dist(graph.size(), {INF, INF}); priority_queue<pair<ll, ll>> pq; for (ll i = 0; i < graph.size(); i++) { if (is_exit[i]) { pq.push({0, i}); dist[i][0] = dist[i][1] = 0; } } while (pq.size()) { auto [d, u] = pq.top(); pq.pop(); d = -d; if (d > dist[u][1]) { continue; } for (auto& [v, w] : graph[u]) { ll cost = w + d; if (cost < dist[v][0]) { if (dist[v][0] != dist[v][1] && dist[v][0] < INF) { dist[v][1] = dist[v][0]; pq.push({-dist[v][1], v}); } dist[v][0] = cost; } else if (cost < dist[v][1]) { dist[v][1] = cost; pq.push({-cost, v}); } } } return dist[0][1]; }

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:29:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::map<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (ll i = 0; i < graph.size(); i++) {
      |                    ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...