#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
struct edge{
int to;
int cost;
};
vector<edge> graph[100003];
pii odl[100003];
int oo=1e9+1;
priority_queue<pair<pii,int>,vector<pair<pii,int>>,greater<pair<pii,int>>> pq;
void Dijkstra(int n){
while(pq.size()){
auto [d,v]=pq.top();
pq.pop();
if (odl[v]<d)continue;
for (auto u : graph[v]){
if (d.second+u.cost<odl[u.to].first){
odl[u.to].first=d.second+u.cost;
pq.push(make_pair(odl[u.to],u.to));
}
else if (d.second+u.cost<odl[u.to].second){
odl[u.to].second=d.second+u.cost;
pq.push(make_pair(odl[u.to],u.to));
}
}
}
}
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
for (int i = 0; i<m; i++){
graph[r[i][0]].push_back({r[i][1],l[i]});
graph[r[i][1]].push_back({r[i][0],l[i]});
}
fill(odl,odl+n,make_pair(oo,oo));
for (int i = 0; i<k; i++){
pq.push({{0,0},p[i]});
odl[p[i]]={0,0};
}
Dijkstra(n);
return odl[0].second;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
6492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
6492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
6492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |