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 <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#define LL long long
#define pll pair<LL,LL>
#define pii pair<int,int>
#define ff first
#define ss second
#define INF 1e18
using namespace std;
int n;
vector<pii> edge[111111];
bool is_esc[111111];
pll dist[111111];
priority_queue<pll,vector<pll>,greater<pll>> pq;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
	n=N;
	for(int i=0;i<M;i++){
		edge[R[i][0]].push_back({R[i][1],L[i]});
		edge[R[i][1]].push_back({R[i][0],L[i]});
	}
	for(int i=0;i<K;i++) is_esc[P[i]]=1;
	for(int i=0;i<N;i++){
		if(is_esc[i]) pq.push({0,i});
		else dist[i].ff=dist[i].ss=INF;
	}
	while(!pq.empty()){
		pll p=pq.top(); pq.pop();
		if(p.ff!=dist[p.ss].ss) continue;
		for(pii u:edge[p.ss]){
			if(dist[u.ff].ff>dist[p.ss].ss+u.ss){
				bool sta=(dist[u.ff].ff==dist[u.ff].ss);
				dist[u.ff].ss=dist[u.ff].ff;
				dist[u.ff].ff=dist[p.ss].ss+u.ss;
				if(!sta && dist[u.ff].ss!=INF) pq.push({dist[u.ff].ss,u.ff});
			}
			else if(dist[u.ff].ss>dist[p.ss].ss+u.ss){
				dist[u.ff].ss=dist[p.ss].ss+u.ss;
				pq.push({dist[u.ff].ss,u.ff});
			}
		}
	}
	return dist[0].ss;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |