#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
const int dydis = 1e5 + 10;
const long long inf = 1e18;
vector<pair<int, int> > gr[dydis];
int n, m, k;
pair<long long, long long> dist[dydis];
int kek[dydis];
bool don[dydis];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
n = N; m = M; k = K;
for(int i = 0; i < n; i++) dist[i] = {inf, inf};
for(int i = 0; i < M; i++) {
gr[R[i][0]].push_back({R[i][1], L[i]});
gr[R[i][1]].push_back({R[i][0], L[i]});
}
priority_queue<pair<int, int> > q;
for(int i = 0; i < k; i++){
q.push({0, P[i]});
}
while(q.size()){
int v = q.top().second;
long long dst = -q.top().first;
q.pop();
if(don[v]) continue;
if(dst != 0 && (dst == inf || dst != dist[v].second)) continue;
don[v] = 1;
for(auto x : gr[v]){
long long gal = x.second + dst;
if(gal < dist[x.first].first){
dist[x.first].second = dist[x.first].first;
dist[x.first].first = gal;
q.push({-dist[x.first].second, x.first});
}else if(gal < dist[x.first].second){
dist[x.first].second = gal;
q.push({-dist[x.first].second, x.first});
}
}
}
return dist[0].second;
}
/*
5 4 3
0 1 2
0 2 3
3 2 1
2 4 4
1 3 4
5 7 2
0 2 4
0 3 3
3 2 2
2 1 10
0 1 100
0 4 7
3 4 9
1 3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
3 ms |
2764 KB |
Output is correct |
5 |
Correct |
3 ms |
2768 KB |
Output is correct |
6 |
Correct |
2 ms |
2636 KB |
Output is correct |
7 |
Correct |
3 ms |
2764 KB |
Output is correct |
8 |
Correct |
4 ms |
2684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
3 ms |
2764 KB |
Output is correct |
5 |
Correct |
3 ms |
2768 KB |
Output is correct |
6 |
Correct |
2 ms |
2636 KB |
Output is correct |
7 |
Correct |
3 ms |
2764 KB |
Output is correct |
8 |
Correct |
4 ms |
2684 KB |
Output is correct |
9 |
Correct |
4 ms |
2892 KB |
Output is correct |
10 |
Correct |
2 ms |
2672 KB |
Output is correct |
11 |
Correct |
3 ms |
2764 KB |
Output is correct |
12 |
Correct |
5 ms |
3148 KB |
Output is correct |
13 |
Correct |
5 ms |
3148 KB |
Output is correct |
14 |
Correct |
2 ms |
2636 KB |
Output is correct |
15 |
Correct |
3 ms |
2764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
2 ms |
2636 KB |
Output is correct |
4 |
Correct |
3 ms |
2764 KB |
Output is correct |
5 |
Correct |
3 ms |
2768 KB |
Output is correct |
6 |
Correct |
2 ms |
2636 KB |
Output is correct |
7 |
Correct |
3 ms |
2764 KB |
Output is correct |
8 |
Correct |
4 ms |
2684 KB |
Output is correct |
9 |
Correct |
4 ms |
2892 KB |
Output is correct |
10 |
Correct |
2 ms |
2672 KB |
Output is correct |
11 |
Correct |
3 ms |
2764 KB |
Output is correct |
12 |
Correct |
5 ms |
3148 KB |
Output is correct |
13 |
Correct |
5 ms |
3148 KB |
Output is correct |
14 |
Correct |
2 ms |
2636 KB |
Output is correct |
15 |
Correct |
3 ms |
2764 KB |
Output is correct |
16 |
Correct |
478 ms |
57732 KB |
Output is correct |
17 |
Correct |
90 ms |
14532 KB |
Output is correct |
18 |
Correct |
115 ms |
16096 KB |
Output is correct |
19 |
Correct |
585 ms |
62140 KB |
Output is correct |
20 |
Correct |
306 ms |
49472 KB |
Output is correct |
21 |
Correct |
40 ms |
7864 KB |
Output is correct |
22 |
Correct |
323 ms |
46256 KB |
Output is correct |