#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5+7;
const long long INF = (long long)1e18+7;
vector<pair<int, int> > g[N];
int n, m;
long long d1[N], d2[N];
int travel_plan(int _N, int _M, int _R[][2], int _L[], int _K, int _P[]) {
n = _N;
m = _M;
for(int i = 0; i < m; ++i) {
int u = _R[i][0], v = _R[i][1], w = _L[i];
u++;
v++;
g[u].push_back({v, w});
g[v].push_back({u, w});
}
for(int i = 1; i <= n; ++i) {
d1[i] = d2[i] = INF;
}
priority_queue<pair<long long, int> > q;
for(int i = 0; i < _K; ++i) {
int v = _P[i]+1;
d1[v]=d2[v]=0;
q.push({0, v});
}
while(!q.empty()) {
int v = q.top().second;
long long cur_d = -q.top().first;
q.pop();
if(cur_d>d2[v]) {
continue;
}
for(auto [to, w] : g[v]) {
if(d2[v]+w<d1[to]) {
d2[to]=d1[to];
d1[to]=d2[v]+w;
q.push({-d2[to], to});
} else {
if(d2[v]+w<d2[to]) {
d2[to]=d2[v]+w;
q.push({-d2[to], to});
}
}
}
}
return d2[1];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
2 ms |
6492 KB |
Output is correct |
6 |
Correct |
2 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
2 ms |
6492 KB |
Output is correct |
6 |
Correct |
2 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
3 ms |
8796 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
2 ms |
6492 KB |
Output is correct |
12 |
Correct |
4 ms |
9052 KB |
Output is correct |
13 |
Correct |
4 ms |
8952 KB |
Output is correct |
14 |
Correct |
2 ms |
6492 KB |
Output is correct |
15 |
Correct |
2 ms |
6612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
2 ms |
6492 KB |
Output is correct |
6 |
Correct |
2 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
3 ms |
8796 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
2 ms |
6492 KB |
Output is correct |
12 |
Correct |
4 ms |
9052 KB |
Output is correct |
13 |
Correct |
4 ms |
8952 KB |
Output is correct |
14 |
Correct |
2 ms |
6492 KB |
Output is correct |
15 |
Correct |
2 ms |
6612 KB |
Output is correct |
16 |
Correct |
306 ms |
61236 KB |
Output is correct |
17 |
Correct |
68 ms |
20432 KB |
Output is correct |
18 |
Correct |
100 ms |
22008 KB |
Output is correct |
19 |
Correct |
375 ms |
68440 KB |
Output is correct |
20 |
Correct |
227 ms |
50956 KB |
Output is correct |
21 |
Correct |
32 ms |
15120 KB |
Output is correct |
22 |
Incorrect |
235 ms |
48996 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |