#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dist1[100005];
ll dist2[100005];
bool ext[100005];
const int MX = 1000000007;
int n;
vector <pair <int, ll>> graf[100005];
set <pair <ll, int>> q;
void sp(){
for(int i=1; i<=n; i++){
if(ext[i]) dist2[i] = 0;
else dist2[i] = MX;
dist1[i] = dist2[i];
q.insert({dist2[i], i});
}
while(!q.empty()){
int v = q.begin()->second;
q.erase(q.begin());
if(v == 1) return;
for(auto pr : graf[v]){
int c = pr.first;
int dis = pr.second+dist2[v];
if(dis < dist1[c]){
q.erase({dist2[c], c});
dist2[c] = dist1[c];
dist1[c] = dis;
q.insert({dist2[c], c});
}
else if(dis < dist2[c]){
q.erase({dist2[c], c});
dist2[c] = dis;
q.insert({dist2[c], c});
}
}
}
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
n = N;
int m = M;
int k = K;
for(int i=0; i<m; i++){
R[i][0]++;
R[i][1]++;
graf[R[i][0]].push_back({R[i][1], L[i]});
graf[R[i][1]].push_back({R[i][0], L[i]});
}
for(int i=0; i<k; i++){
P[i]++;
ext[P[i]] = 1;
}
sp();
return dist2[1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2936 KB |
Output is correct |
2 |
Correct |
5 ms |
2680 KB |
Output is correct |
3 |
Correct |
5 ms |
2808 KB |
Output is correct |
4 |
Correct |
5 ms |
2936 KB |
Output is correct |
5 |
Correct |
5 ms |
2936 KB |
Output is correct |
6 |
Correct |
5 ms |
2812 KB |
Output is correct |
7 |
Correct |
5 ms |
2808 KB |
Output is correct |
8 |
Correct |
7 ms |
2936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2936 KB |
Output is correct |
2 |
Correct |
5 ms |
2680 KB |
Output is correct |
3 |
Correct |
5 ms |
2808 KB |
Output is correct |
4 |
Correct |
5 ms |
2936 KB |
Output is correct |
5 |
Correct |
5 ms |
2936 KB |
Output is correct |
6 |
Correct |
5 ms |
2812 KB |
Output is correct |
7 |
Correct |
5 ms |
2808 KB |
Output is correct |
8 |
Correct |
7 ms |
2936 KB |
Output is correct |
9 |
Correct |
6 ms |
3064 KB |
Output is correct |
10 |
Correct |
5 ms |
2680 KB |
Output is correct |
11 |
Correct |
6 ms |
2808 KB |
Output is correct |
12 |
Correct |
8 ms |
3320 KB |
Output is correct |
13 |
Correct |
8 ms |
3448 KB |
Output is correct |
14 |
Correct |
4 ms |
2808 KB |
Output is correct |
15 |
Correct |
5 ms |
2808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2936 KB |
Output is correct |
2 |
Correct |
5 ms |
2680 KB |
Output is correct |
3 |
Correct |
5 ms |
2808 KB |
Output is correct |
4 |
Correct |
5 ms |
2936 KB |
Output is correct |
5 |
Correct |
5 ms |
2936 KB |
Output is correct |
6 |
Correct |
5 ms |
2812 KB |
Output is correct |
7 |
Correct |
5 ms |
2808 KB |
Output is correct |
8 |
Correct |
7 ms |
2936 KB |
Output is correct |
9 |
Correct |
6 ms |
3064 KB |
Output is correct |
10 |
Correct |
5 ms |
2680 KB |
Output is correct |
11 |
Correct |
6 ms |
2808 KB |
Output is correct |
12 |
Correct |
8 ms |
3320 KB |
Output is correct |
13 |
Correct |
8 ms |
3448 KB |
Output is correct |
14 |
Correct |
4 ms |
2808 KB |
Output is correct |
15 |
Correct |
5 ms |
2808 KB |
Output is correct |
16 |
Correct |
901 ms |
80520 KB |
Output is correct |
17 |
Correct |
191 ms |
24056 KB |
Output is correct |
18 |
Correct |
209 ms |
25848 KB |
Output is correct |
19 |
Correct |
1402 ms |
86472 KB |
Output is correct |
20 |
Correct |
388 ms |
67448 KB |
Output is correct |
21 |
Correct |
81 ms |
11640 KB |
Output is correct |
22 |
Correct |
446 ms |
65892 KB |
Output is correct |