//#include "crocodile.h"
#include "bits/stdc++.h"
using namespace std;
#define f first
#define s second
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
vector<pair<int, int> > adj[n];
for(int i=0; i<m; ++i)
adj[r[i][1]].push_back({r[i][0], l[i]});
vector<pair<int, int> > d(n, {1e9+5, 1e9+5});
vector<bool> vis(n, 0);
priority_queue<pair<int, int> > pq;
for(int i=0; i<k; ++i){
d[p[i]].f = 0;
pq.push({0, p[i]});
}
while(!pq.empty()){
int s = pq.top().s; pq.pop();
if(vis[s]) continue;
vis[s] = 1;
for(auto p : adj[s]){
int u = p.f, w = p.s;
if(d[s].f + w < d[u].f){
d[u].f = d[s].f + w;
pq.push({-d[u].f, u});
} else if(d[s].f + w < d[u].s)
d[u].s = d[s].f + w;
}
}
if(d[0].s == 1e9+5) return -1;
return d[0].s;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |