#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
const int nx=1e5+5;
int vs[nx], dp[nx];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
vector<vector<pair<int, int>>> d(nx);
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for (int i=0; i<M; i++) d[R[i][0]].push_back({R[i][1], L[i]}), d[R[i][1]].push_back({R[i][0], L[i]});
for (int i=0; i<K; i++) pq.push({0, P[i]}), vs[P[i]]=1;
while (!pq.empty())
{
auto [cw, cl]=pq.top();
//printf("%d %d %d\n", cl, cw, vs[cl]);
pq.pop();
if (vs[cl]==2) continue;
vs[cl]++;
if (vs[cl]==1) continue;
dp[cl]=cw;
for (auto [v, w]:d[cl])
{
if (vs[v]!=2) pq.push({dp[cl]+w, v});
}
}
return dp[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6744 KB |
Output is correct |
2 |
Correct |
2 ms |
6744 KB |
Output is correct |
3 |
Correct |
2 ms |
6744 KB |
Output is correct |
4 |
Correct |
2 ms |
6744 KB |
Output is correct |
5 |
Correct |
2 ms |
6744 KB |
Output is correct |
6 |
Correct |
2 ms |
6744 KB |
Output is correct |
7 |
Correct |
2 ms |
6744 KB |
Output is correct |
8 |
Correct |
2 ms |
6744 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6744 KB |
Output is correct |
2 |
Correct |
2 ms |
6744 KB |
Output is correct |
3 |
Correct |
2 ms |
6744 KB |
Output is correct |
4 |
Correct |
2 ms |
6744 KB |
Output is correct |
5 |
Correct |
2 ms |
6744 KB |
Output is correct |
6 |
Correct |
2 ms |
6744 KB |
Output is correct |
7 |
Correct |
2 ms |
6744 KB |
Output is correct |
8 |
Correct |
2 ms |
6744 KB |
Output is correct |
9 |
Correct |
4 ms |
7000 KB |
Output is correct |
10 |
Correct |
2 ms |
6744 KB |
Output is correct |
11 |
Correct |
3 ms |
7000 KB |
Output is correct |
12 |
Correct |
5 ms |
7512 KB |
Output is correct |
13 |
Correct |
5 ms |
7512 KB |
Output is correct |
14 |
Correct |
2 ms |
6744 KB |
Output is correct |
15 |
Correct |
3 ms |
6744 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6744 KB |
Output is correct |
2 |
Correct |
2 ms |
6744 KB |
Output is correct |
3 |
Correct |
2 ms |
6744 KB |
Output is correct |
4 |
Correct |
2 ms |
6744 KB |
Output is correct |
5 |
Correct |
2 ms |
6744 KB |
Output is correct |
6 |
Correct |
2 ms |
6744 KB |
Output is correct |
7 |
Correct |
2 ms |
6744 KB |
Output is correct |
8 |
Correct |
2 ms |
6744 KB |
Output is correct |
9 |
Correct |
4 ms |
7000 KB |
Output is correct |
10 |
Correct |
2 ms |
6744 KB |
Output is correct |
11 |
Correct |
3 ms |
7000 KB |
Output is correct |
12 |
Correct |
5 ms |
7512 KB |
Output is correct |
13 |
Correct |
5 ms |
7512 KB |
Output is correct |
14 |
Correct |
2 ms |
6744 KB |
Output is correct |
15 |
Correct |
3 ms |
6744 KB |
Output is correct |
16 |
Correct |
439 ms |
70204 KB |
Output is correct |
17 |
Correct |
57 ms |
16980 KB |
Output is correct |
18 |
Correct |
73 ms |
18256 KB |
Output is correct |
19 |
Correct |
481 ms |
72652 KB |
Output is correct |
20 |
Correct |
350 ms |
63036 KB |
Output is correct |
21 |
Correct |
30 ms |
10576 KB |
Output is correct |
22 |
Correct |
323 ms |
50000 KB |
Output is correct |