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>> q;
vector<vector<pair<int,int>>> edges(N);
for(int i = 0; i < M; ++i) {
edges[R[i][0]].push_back({R[i][1], L[i]});
edges[R[i][1]].push_back({R[i][0], L[i]});
}
vector<bool> seen(N), vis(N);
vector<int> dist(N);
for(int i = 0; i < K; ++i) {
q.push({0, P[i]});
seen[P[i]] = 1;
}
while(!q.empty()) {
pair<int,int> p = q.top(); q.pop();
if(!seen[p.second]) {
seen[p.second] = 1;
continue;
}
if(vis[p.second]) continue;
vis[p.second] = true;
dist[p.second] = -p.first;
for(pair<int,int> to : edges[p.second]) {
q.push({-to.second+p.first, to.first});
}
}
return dist[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... |