# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1129818 | alex_2008 | Crocodile's Underground City (IOI11_crocodile) | C++20 | 406 ms | 54996 KiB |
#include "crocodile.h"
#include <queue>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
const int N = 1e5 + 10;
int visited[N];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
vector <vector<pair<int, int>>> G(N);
for (int i = 0; i < M; i++) {
G[R[i][0]].push_back({ R[i][1], L[i] });
G[R[i][1]].push_back({ R[i][0], L[i] });
}
priority_queue <pair<int, int>> PQ;
for (int i = 0; i < K; i++) {
visited[P[i]] = 1;
PQ.push({ 0, P[i] });
}
while (!PQ.empty()) {
int d = -PQ.top().first, v = PQ.top().second; PQ.pop();
if (visited[v] == 2) continue;
visited[v]++;
if (visited[v] == 1) {
continue;
}
if (v == 0) return d;
for (auto it : G[v]) {
PQ.push({ -(d + it.second), it.first });
}
}
}
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... |