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>
using namespace std;
#include "crocodile.h"
#define pb push_back
#define fi first
#define se second
const int nax=1e5+5;
vector<pair<int,int>> adj[nax];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for (int i = 0; i < M; ++i)
{
adj[R[i][0]].pb({R[i][1],L[i]});
adj[R[i][1]].pb({R[i][0],L[i]});
}
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
int vis[N];
memset(vis,0,sizeof vis);
for (int i = 0; i < K; ++i)
{
pq.push({0,P[i]});
vis[P[i]]++;
}
while(!pq.empty()){
pair<int,int> node=pq.top();
pq.pop();
if(vis[node.se]++ == 1){
if(node.se==0) return node.fi;
for(auto u:adj[node.se]){
pq.push({u.se+node.fi,u.fi});
}
}
}
return N;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |