# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
852331 | uped | Crocodile's Underground City (IOI11_crocodile) | C++14 | 656 ms | 77828 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]);
}
priority_queue<pair<int, int>> pq;
vector<pair<int, int>> distance(N, {-1, -1});
vector<bool> is_exit(N);
for (int i = 0; i < K; ++i) {
is_exit[P[i]] = true;
pq.emplace(0, P[i]);
distance[P[i]] = {0, 0};
}
while (!pq.empty()) {
auto [dist, a] = pq.top(); pq.pop();
auto& [min, min2] = distance[a];
if (min == -1 || -dist < min) {
min2 = min;
min = -dist;
} else if (min2 == -1 || -dist < min2) {
min2 = -dist;
} else if (!is_exit[a]) {
continue;
}
if (min2 == -1) continue;
for (auto [b, w] : adj[a]) {
if (!is_exit[b]) {
pq.emplace((min2 + w) * -1, b);
}
}
}
return distance[0].second;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |