#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
vector<vector<pair<int, i64>>> edges(N);
for (int i = 0; i < M; ++i) {
edges[R[i][1]].emplace_back(R[i][0], i64(L[i]));
edges[R[i][0]].emplace_back(R[i][1], i64(L[i]));
}
vector<int> visited(N, 0);
vector<i64> d(N, 1e18);
priority_queue<pair<i64, int>> q;
for (int i = 0; i < K; ++i) {
visited[P[i]] = 1;
d[P[i]] = 0;
q.push({0, P[i]});
}
while (!q.empty()) {
i64 dist = -q.top().first;
int node = q.top().second;
q.pop();
if (visited[node] >= 2) continue;
++visited[node];
if (visited[node] < 2) continue;
d[node] = dist;
for (auto [next, weight] : edges[node]) {
if (visited[next] < 2) {
q.push({-dist - weight, next});
}
}
}
return d[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
444 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
444 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
900 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
444 KB |
Output is correct |
12 |
Correct |
5 ms |
1364 KB |
Output is correct |
13 |
Correct |
5 ms |
1492 KB |
Output is correct |
14 |
Correct |
1 ms |
312 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
444 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
900 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
444 KB |
Output is correct |
12 |
Correct |
5 ms |
1364 KB |
Output is correct |
13 |
Correct |
5 ms |
1492 KB |
Output is correct |
14 |
Correct |
1 ms |
312 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
651 ms |
95680 KB |
Output is correct |
17 |
Correct |
76 ms |
17228 KB |
Output is correct |
18 |
Correct |
92 ms |
19592 KB |
Output is correct |
19 |
Correct |
750 ms |
101144 KB |
Output is correct |
20 |
Correct |
398 ms |
81820 KB |
Output is correct |
21 |
Correct |
36 ms |
7884 KB |
Output is correct |
22 |
Correct |
393 ms |
62880 KB |
Output is correct |