# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
852328 | 2023-09-21T15:25:23 Z | uped | Crocodile's Underground City (IOI11_crocodile) | C++14 | 1 ms | 4440 KB |
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { vector<vector<pair<int, int>>> adj(N); for (int i = 0; i < M; ++i) { adj[R[i][0]].emplace_back(R[i][1], L[i]); adj[R[i][1]].emplace_back(R[i][0], L[i]); } vector<bool> is_exit(N); for (int i = 0; i < K; ++i) { is_exit[P[i]] = true; } priority_queue<pair<int, int>> pq; vector<int> distance(N, INT32_MAX); pq.emplace(0, 0); distance[0] = 0; int ans = INT32_MAX; while (!pq.empty()) { auto [dist, a] = pq.top(); pq.pop(); if (-dist != distance[a]) continue; pair<int,int> min {-1, -1}; for (auto [b, w] : adj[a]) { if (is_exit[b]) { if (min.first == -1 || w < min.first) { min.second = min.first; min.first = w; } else if (min.second == -1 || w < min.second) { min.second = w; } } else if (distance[a] + w < distance[b]) { distance[b] = distance[a] + w; pq.emplace(-distance[b], b); } } if (min.second != -1) { ans = ::min(ans, distance[a] + min.second); } } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4440 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4440 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4440 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |