#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
vector<vector<array<int, 2>>> graph(n);
for(int i = 0; i < m; i ++)
graph[r[i][0]].push_back({r[i][1], l[i]}), graph[r[i][1]].push_back({r[i][0], l[i]});
vector<int> mins1(n, 1e9), mins2(n, 1e9);
for(int i = 0; i < k; i ++)
mins1[p[i]] = 0, mins2[p[i]] = 0;
set<array<int, 2>> st;
for(int i = 0; i < k; i ++)
st.insert({0, p[i]});
while(!st.empty()){
auto [d, x] = *st.begin();
st.erase(st.begin());
for(auto [y, t] : graph[x]){
if(mins1[y] > t + d){
st.erase({mins2[y], y});
mins2[y] = mins1[y];
mins1[y] = t + d;
st.insert({mins2[y], y});
}
else if(mins2[y] > t + d){
st.erase({mins2[y], y});
mins2[y] = t + d;
st.insert({mins2[y], y});
}
}
}
return mins2[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
2 ms |
4696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
2 ms |
4696 KB |
Output is correct |
9 |
Correct |
2 ms |
4696 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
3 ms |
2908 KB |
Output is correct |
13 |
Correct |
2 ms |
4956 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
2 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
2 ms |
4696 KB |
Output is correct |
9 |
Correct |
2 ms |
4696 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
3 ms |
2908 KB |
Output is correct |
13 |
Correct |
2 ms |
4956 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
343 ms |
54952 KB |
Output is correct |
17 |
Correct |
50 ms |
15528 KB |
Output is correct |
18 |
Correct |
90 ms |
16988 KB |
Output is correct |
19 |
Correct |
471 ms |
60496 KB |
Output is correct |
20 |
Correct |
189 ms |
47772 KB |
Output is correct |
21 |
Correct |
29 ms |
9048 KB |
Output is correct |
22 |
Correct |
197 ms |
44368 KB |
Output is correct |