#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,e) for (int i = s; i <= e; ++i)
#define rrep(i,s,e) for (int i = s; i >= e; --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int travel_plan (int n, int m, int r[][2], int l[], int k, int p[]) {
vii neibs[n];
rep (i,0,m-1) {
neibs[r[i][0]].pb({r[i][1], l[i]});
neibs[r[i][1]].pb({r[i][0], l[i]});
}
multiset<int> doors[n];
bool done[n]={};
priority_queue<ii, vii, greater<ii>> pq;
rep (i,0,k-1) pq.push({0, p[i]});
while (!pq.empty()) {
int dist = pq.top().fi, u = pq.top().se;
pq.pop();
if (done[u]) continue;
if (u==0) return dist;
for (ii vd : neibs[u]) {
int v = vd.fi, d = vd.se;
doors[v].insert(d+dist);
if ((int)doors[v].size()>1) pq.push({*(++doors[v].begin()), v});
}
}
assert(0==1);
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1948 ms |
262148 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1948 ms |
262148 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1948 ms |
262148 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |