#include<bits/stdc++.h>
#include "crocodile.h"
using namespace std;
const int N=1000000004;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,K,P[100009],bo[100009];
vector <pair <long long, long long> > v[100009];
priority_queue <pair <long long, long long> > s;
pair <long long, long long> dis[100009],PA;
void UPD(long long q, long long w){
if(dis[q].first>w){
dis[q].second=dis[q].first;dis[q].first=w;
}else{
if(dis[q].second>w) dis[q].second=w;
}
}
int travel_plan(int NN, int MM, int RR[][2], int LL[], int KK, int PP[])
{
a=NN;b=MM;
for(i=1; i<=b; i++){
c=RR[i-1][0]+1;d=RR[i-1][1]+1;e=LL[i-1];
v[c].push_back({d,e});v[d].push_back({c,e});
}
K=KK;
for(i=1; i<=K; i++){
P[i]=PP[i-1]+1;
}
for(i=0; i<=a+1; i++){
dis[i]={N,N};
}
for(i=1; i<=K; i++){
s.push({0,P[i]});
dis[P[i]]={0,0};
}
while(s.size()){
while(s.size()){
PA=s.top();
if(bo[PA.second]==1){
s.pop();
}else{
break;
}
}
if(s.size()==0) break;
c=PA.second;d=-PA.first;s.pop();bo[c]=1;
for(vector <pair <long long, long long> >::iterator it=v[c].begin(); it!=v[c].end(); it++){
if(dis[(*it).first].second>dis[c].second+(*it).second){
UPD((*it).first,dis[c].second+(*it).second);
s.push({-dis[(*it).first].second,(*it).first});
}
}
}
return dis[1].second;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2772 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2772 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
3 ms |
2804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2772 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2772 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
3 ms |
2804 KB |
Output is correct |
9 |
Correct |
4 ms |
3028 KB |
Output is correct |
10 |
Correct |
2 ms |
2600 KB |
Output is correct |
11 |
Correct |
2 ms |
2772 KB |
Output is correct |
12 |
Correct |
5 ms |
3408 KB |
Output is correct |
13 |
Correct |
5 ms |
3424 KB |
Output is correct |
14 |
Correct |
2 ms |
2644 KB |
Output is correct |
15 |
Correct |
3 ms |
2772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2772 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2772 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
3 ms |
2804 KB |
Output is correct |
9 |
Correct |
4 ms |
3028 KB |
Output is correct |
10 |
Correct |
2 ms |
2600 KB |
Output is correct |
11 |
Correct |
2 ms |
2772 KB |
Output is correct |
12 |
Correct |
5 ms |
3408 KB |
Output is correct |
13 |
Correct |
5 ms |
3424 KB |
Output is correct |
14 |
Correct |
2 ms |
2644 KB |
Output is correct |
15 |
Correct |
3 ms |
2772 KB |
Output is correct |
16 |
Correct |
453 ms |
79864 KB |
Output is correct |
17 |
Correct |
93 ms |
20292 KB |
Output is correct |
18 |
Correct |
116 ms |
22936 KB |
Output is correct |
19 |
Correct |
546 ms |
88452 KB |
Output is correct |
20 |
Correct |
270 ms |
68128 KB |
Output is correct |
21 |
Correct |
42 ms |
10548 KB |
Output is correct |
22 |
Correct |
291 ms |
61512 KB |
Output is correct |