This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |