#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pli pair<ll, int>
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
vector<vector<pli>> g (N);
for (int i = 0; i < M; i++) {
g[R[i][0]].push_back({L[i], R[i][1]});
g[R[i][1]].push_back({L[i], R[i][0]});
}
vector<bool> odw (N, 0);
vector<ll> d (N, -1);
priority_queue<pli, vector<pli>, greater<pli>> pq;
for (int i = 0; i < K; i++) {
d[P[i]] = 0;
pq.push({(ll)0, P[i]});
}
vector<ll> score (N, 0);
while(!pq.empty()) {
pli x = pq.top(); pq.pop();
if (odw[x.second]) continue;
odw[x.second] = 1;
score[x.second] = x.first;
for (pli i : g[x.second]) {
if (odw[i.second]) {
continue;
}
ll l = x.first+i.first;
if (d[i.second] == -1) {
d[i.second] = l;
}
else {
pq.push({max(d[i.second], l), i.second});
d[i.second] = min(d[i.second], l);
}
}
}
return score[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
0 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
0 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4956 KB |
Output is correct |
10 |
Correct |
0 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4700 KB |
Output is correct |
12 |
Correct |
3 ms |
5468 KB |
Output is correct |
13 |
Correct |
3 ms |
5468 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
0 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4956 KB |
Output is correct |
10 |
Correct |
0 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4700 KB |
Output is correct |
12 |
Correct |
3 ms |
5468 KB |
Output is correct |
13 |
Correct |
3 ms |
5468 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
348 ms |
97724 KB |
Output is correct |
17 |
Correct |
36 ms |
19536 KB |
Output is correct |
18 |
Correct |
47 ms |
21844 KB |
Output is correct |
19 |
Correct |
354 ms |
103808 KB |
Output is correct |
20 |
Correct |
259 ms |
83896 KB |
Output is correct |
21 |
Correct |
19 ms |
11096 KB |
Output is correct |
22 |
Correct |
234 ms |
64920 KB |
Output is correct |