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>
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
priority_queue < pair < int, int > > pq;
vector < pair < int, int > > v[N + 1];
long long d[N + 1], f[N + 1];
memset(d, 0, sizeof d);
memset(f, 0, sizeof f);
for(int i = 0; i < M; i++) {
v[R[i][0]].push_back({R[i][1], L[i]});
v[R[i][1]].push_back({R[i][0], L[i]});
}
for(int i = 0; i < K; i++) pq.push({0, P[i]}), f[P[i]] = 1;
while(pq.size()) {
pair < int, int > p = pq.top();
pq.pop();
int dist = p.first;
int u = p.second;
if(!f[u]) {
f[u] = 1;
continue;
}
if(f[u] == 2) continue;
if(f[u] == 1) f[u] = 2;
d[u] = -dist;
for(auto x : v[u]) pq.push({dist - x.second, x.first});
}
return d[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... |