#include <bits/stdc++.h>
#include "crocodile.h"
#define ll long long
using namespace std;
const ll INF = 1e18+7;
const int MAXN = 1e5+7;
vector<pair<int,int> > g[MAXN];
priority_queue<pair<ll, int>> kp;
ll d[MAXN][2]; bool visited[MAXN];
int travel_plan(int N,int M,int R[][2],int L[],int K,int P[]){
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]});
}
for(int i=0;i<N;i++) d[i][0]=d[i][1]=INF;
for(int i=0;i<K;i++){
d[P[i]][0]=d[P[i]][1]=0;
kp.push({0,P[i]});
}
//for(int i=0;i<N;i++) cout<<i<<' '<<d[i][0]<<' '<<d[i][1]<<'\n';
while(!kp.empty()){
int x=kp.top().second;
kp.pop();
if(visited[x]) continue;
visited[x]=1;
//cout<<"x="<<x<<'\n';
for(auto s:g[x]){
if(d[s.first][0]>d[s.first][1]) swap(d[s.first][0],d[s.first][1]);
if(max(d[x][0],d[x][1])+s.second<d[s.first][1]){
d[s.first][1]=min(INF, max(d[x][0],d[x][1])+s.second);
if(max(d[s.first][0],d[s.first][1])<INF) kp.push({-max(d[s.first][1], d[s.first][0]),s.first});
}
}
}
return (int)max(d[0][0],d[0][1]);
}/*
int main(){
int n,m,k;
int R[MAXN][2], L[MAXN], P[MAXN];
cin>>n>>m>>k;
for(int i=1;i<=m;i++) cin>>R[i-1][0]>>R[i-1][1]>>L[i-1];
for(int i=0;i<k;i++) cin>>P[i];
cout<<travel_plan(n,m,R,L,k,P)<<'\n';
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6488 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
2 ms |
6492 KB |
Output is correct |
6 |
Correct |
3 ms |
6600 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6488 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
2 ms |
6492 KB |
Output is correct |
6 |
Correct |
3 ms |
6600 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
3 ms |
6748 KB |
Output is correct |
10 |
Correct |
2 ms |
6492 KB |
Output is correct |
11 |
Correct |
3 ms |
6604 KB |
Output is correct |
12 |
Correct |
4 ms |
6748 KB |
Output is correct |
13 |
Correct |
4 ms |
7004 KB |
Output is correct |
14 |
Correct |
2 ms |
6492 KB |
Output is correct |
15 |
Correct |
2 ms |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6488 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
2 ms |
6492 KB |
Output is correct |
6 |
Correct |
3 ms |
6600 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
3 ms |
6748 KB |
Output is correct |
10 |
Correct |
2 ms |
6492 KB |
Output is correct |
11 |
Correct |
3 ms |
6604 KB |
Output is correct |
12 |
Correct |
4 ms |
6748 KB |
Output is correct |
13 |
Correct |
4 ms |
7004 KB |
Output is correct |
14 |
Correct |
2 ms |
6492 KB |
Output is correct |
15 |
Correct |
2 ms |
6492 KB |
Output is correct |
16 |
Correct |
330 ms |
60372 KB |
Output is correct |
17 |
Correct |
55 ms |
16728 KB |
Output is correct |
18 |
Correct |
73 ms |
18124 KB |
Output is correct |
19 |
Correct |
411 ms |
66972 KB |
Output is correct |
20 |
Correct |
218 ms |
52132 KB |
Output is correct |
21 |
Correct |
28 ms |
12368 KB |
Output is correct |
22 |
Correct |
252 ms |
49572 KB |
Output is correct |