#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
const ll INF = 1e18;
int n, isExit[N]; ll d[N][2];
vector< pair<int,int> > g[N];
priority_queue< pair<ll,int>, vector< pair<ll,int> >, greater< pair<ll,int> > > q;
int travel_plan(int N_, int M, int R[][2], int L[], int K, int P[]) {
n = N_;
for(int i = 0; i < M; i++) {
g[R[i][0]].push_back({R[i][1], L[i]});
g[R[i][1]].push_back({R[i][0], L[i]});
}
for(int i = 0; i < n; i++) d[i][0] = d[i][1] = INF;
for(int i = 0; i < K; i++) {
d[P[i]][0] = d[P[i]][1] = 0;
q.push({0, P[i]});
}
while(!q.empty()) {
auto top = q.top(); q.pop();
int u = top.second; ll cw = top.first;
if(cw > d[u][1]) continue;
for(auto e : g[u]) {
if(d[u][1] + e.second <= d[e.first][0]) {
swap(d[e.first][0], d[e.first][1]);
d[e.first][0] = d[u][1] + e.second;
q.push({d[e.first][0], e.first});
}
else if(d[u][1] + e.second < d[e.first][1]) {
d[e.first][1] = d[u][1] + e.second;
q.push({d[e.first][1], e.first});
}
}
}
return d[0][1];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
2680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
2680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
2680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |