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 int long long
#define pi pair<long long, long long>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
vector <pi> adj[N + 5];
long long dist[N+5][2], vis[N+1];
for(int i=0;i<=N;i++)dist[i][0] = dist[i][1] = 1e10;
for(int i=0;i<M;i++){
adj[R[i][0]].push_back({R[i][1], L[i]});
adj[R[i][1]].push_back({R[i][0], L[i]});
}
priority_queue <pi, vector<pi>, greater<pi> > pq;
for(int i=0;i<K;i++){
dist[P[i]][0] = dist[P[i]][1] = 0;
vis[i] = 2;
pq.push({0, P[i]});
}
while(!pq.empty()){
long long x = pq.top().fi, y = pq.top().se;
pq.pop();
if(vis[y] == 2)continue;
dist[y][vis[y]++] = x;
for(auto [i, j] : adj[y]){
if(vis[i] < 2)pq.push({x+j, i});
}
}
return dist[0][1];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |