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"crocodile.h"
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
typedef long long ll;
vector<pair<ll,ll>>g[100005];
pair<ll,ll>a[100005];
ll inf=2e9;
int travel_plan(int n,int m,int r[][2],int l[],int k,int p[]){
for(int i=0;i<n;i++)a[i]={inf,inf};
multiset<pair<ll,ll>>q;
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<k;i++)
q.insert({0,p[i]}),a[p[i]]={0,0};
while(!q.empty()){
ll len=q.begin()->fr;
ll v=q.begin()->sc;
q.erase(q.begin());
if(len>a[v].sc)continue;
for(auto to:g[v])
if(a[to.fr].sc>len+to.sc){
a[to.fr].sc=len+to.sc;
if(a[to.fr].fr>a[to.fr].sc)swap(a[to.fr].fr,a[to.fr].sc);
if(a[to.fr].sc<inf)q.insert({a[to.fr].sc,to.fr});
}
}
return a[0].sc;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |