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;
#define MAX_N 100000
#define MAX_M 10000000
vector<pair<int, long long>> adj[MAX_N];
long long dis[MAX_N];
int vis[MAX_N];
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]].emplace_back(R[i][1], L[i]);
adj[R[i][1]].emplace_back(R[i][0], L[i]);
}
fill(dis, dis+N, 1e18);
priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
for(int i = 0; i < K; ++i){
vis[P[i]] = 1;
pq.emplace(0LL, P[i]);
}
while(!pq.empty()){
auto [d, u] = pq.top(); pq.pop();
vis[u]++;
if(dis[u] != 1e18) continue;
if(vis[u] == 2){
dis[u] = d;
for(auto [v, w] : adj[u]) pq.emplace(d + w, v);
}
}
return dis[0];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |