# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
857877 | 2023-10-07T06:24:20 Z | asdasdqwer | Crocodile's Underground City (IOI11_crocodile) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; #define int int64_t #define pii pair<int, int> int travel_plan(int n, int m, int R[][2], int L[], int k, int p[]) { vector<vector<pii>> g(n); for (int i=0;i<m;i++) { int a = R[i][0], b = R[i][1]; int c = L[i]; g[a].push_back({b, c}); g[b].push_back({a, c}); } vector<pii> dist(n, make_pair((int)1e16, (int)1e16)); for (int i=0;i<k;i++) { dist[p[i]] = {0, 0}; } priority_queue<pii> pq; for (int i=0;i<n;i++) { pq.push({-dist[i].second, i}); } vector<bool> proc(n, false); while (!pq.empty()) { pii t=pq.top();pq.pop(); int node=t.second; if (proc[node]) continue; proc[node] = true; for (auto x:g[node]) { if (dist[node].second + x.second < dist[x.first].first) { dist[x.first].second = dist[x.first].first; dist[x.first].first = dist[node].second + x.second; pq.push({-dist[x.first].second, x.first}); } else if (dist[node].second + x.second < dist[x.first].second) { dist[x.first].second = dist[node].second + x.second; pq.push({-dist[x.first].second, x.first}); } } } return dist[0].second; }