#include <bits/stdc++.h>
//#include "factories.h"
#include "crocodile.h"
#define f first
#define s second
using namespace std;
const int maxn = 1e5 + 69;
vector<pair<int, int>> g[maxn];
vector<int> d(maxn, 1e9);
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
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]});
}
priority_queue<pair<int, int>> pq;
for(int i = 0;i < K;i++) {
for(auto u : g[P[i]])
pq.push({-u.s, u.f});
d[P[i]] = 0;
}
vector<int> cnt(N);
while(!pq.empty()) {
auto u = pq.top();
pq.pop();
if(d[u.s] != 1e9)
continue;
cnt[u.s]++;
if(cnt[u.s] == 2) {
d[u.s] = -u.f;
for(auto v : g[u.s])
pq.push({-v.s + u.f, v.f});
}
}
return d[0];
}
// int main()
// {
// ios_base::sync_with_stdio(false);
// cin.tie(0);
// cout.tie(0);
// int tt = 1;
// //cin >> tt;
// while(tt--) {
// int n, m;
// cin >> n >> m;
// int r[m][2];
// for(int i = 0;i < m;i++)
// cin >> r[i][0] >> r[i][1];
// int l[m];
// for(int i = 0;i < m;i++)
// cin >> l[i];
// int k;
// cin >> k;
// int p[k];
// for(int i = 0;i < k;i++)
// cin >> p[i];
// cout << travel_plan(n, m, r, l, k, p);
// }
// return 0;
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3028 KB |
Output is correct |
2 |
Correct |
1 ms |
3028 KB |
Output is correct |
3 |
Correct |
1 ms |
3028 KB |
Output is correct |
4 |
Correct |
2 ms |
3028 KB |
Output is correct |
5 |
Correct |
2 ms |
3028 KB |
Output is correct |
6 |
Correct |
2 ms |
3028 KB |
Output is correct |
7 |
Correct |
2 ms |
3028 KB |
Output is correct |
8 |
Correct |
2 ms |
3028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3028 KB |
Output is correct |
2 |
Correct |
1 ms |
3028 KB |
Output is correct |
3 |
Correct |
1 ms |
3028 KB |
Output is correct |
4 |
Correct |
2 ms |
3028 KB |
Output is correct |
5 |
Correct |
2 ms |
3028 KB |
Output is correct |
6 |
Correct |
2 ms |
3028 KB |
Output is correct |
7 |
Correct |
2 ms |
3028 KB |
Output is correct |
8 |
Correct |
2 ms |
3028 KB |
Output is correct |
9 |
Correct |
3 ms |
3412 KB |
Output is correct |
10 |
Correct |
1 ms |
3028 KB |
Output is correct |
11 |
Correct |
3 ms |
3156 KB |
Output is correct |
12 |
Correct |
6 ms |
3796 KB |
Output is correct |
13 |
Correct |
6 ms |
3796 KB |
Output is correct |
14 |
Correct |
2 ms |
3028 KB |
Output is correct |
15 |
Correct |
2 ms |
3156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3028 KB |
Output is correct |
2 |
Correct |
1 ms |
3028 KB |
Output is correct |
3 |
Correct |
1 ms |
3028 KB |
Output is correct |
4 |
Correct |
2 ms |
3028 KB |
Output is correct |
5 |
Correct |
2 ms |
3028 KB |
Output is correct |
6 |
Correct |
2 ms |
3028 KB |
Output is correct |
7 |
Correct |
2 ms |
3028 KB |
Output is correct |
8 |
Correct |
2 ms |
3028 KB |
Output is correct |
9 |
Correct |
3 ms |
3412 KB |
Output is correct |
10 |
Correct |
1 ms |
3028 KB |
Output is correct |
11 |
Correct |
3 ms |
3156 KB |
Output is correct |
12 |
Correct |
6 ms |
3796 KB |
Output is correct |
13 |
Correct |
6 ms |
3796 KB |
Output is correct |
14 |
Correct |
2 ms |
3028 KB |
Output is correct |
15 |
Correct |
2 ms |
3156 KB |
Output is correct |
16 |
Correct |
664 ms |
56716 KB |
Output is correct |
17 |
Correct |
61 ms |
13728 KB |
Output is correct |
18 |
Correct |
83 ms |
15200 KB |
Output is correct |
19 |
Correct |
658 ms |
75448 KB |
Output is correct |
20 |
Correct |
489 ms |
66428 KB |
Output is correct |
21 |
Correct |
34 ms |
7884 KB |
Output is correct |
22 |
Correct |
422 ms |
46756 KB |
Output is correct |