#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
pii dis[100001]; //first,second
vector<pii> adj[100001];
priority_queue<pii, vector<pii>, greater<pii>> q; //dis,node
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]) {
for (int i=0; i<n; ++i) dis[i]={LLONG_MAX,LLONG_MAX};
for (int i=0; i<m; ++i) {
ll a=R[i][0], b=R[i][1], w=L[i];
adj[a].push_back(pii(b,w));
adj[b].push_back(pii(a,w));
}
for (int i=0; i<k; ++i) {
int x=P[i];
dis[x]={0,0};
q.push({0,x});
}
while (!q.empty()) {
ll d=q.top().first, node=q.top().second;
q.pop();
if (d>dis[node].second) continue;
for (auto s : adj[node]) {
ll des=s.first, w=s.second;
ll now=dis[des].second;
if (dis[des].first>d+w) {
dis[des].second=dis[des].first;
dis[des].first=d+w;
} else if (dis[des].second>d+w) dis[des].second=d+w;
if (dis[des].second<now) q.push({dis[des].second,des});
}
}
return dis[0].second;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2772 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2672 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2772 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2672 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2772 KB |
Output is correct |
9 |
Correct |
4 ms |
3052 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
3 ms |
2800 KB |
Output is correct |
12 |
Correct |
5 ms |
3412 KB |
Output is correct |
13 |
Correct |
5 ms |
3412 KB |
Output is correct |
14 |
Correct |
2 ms |
2664 KB |
Output is correct |
15 |
Correct |
2 ms |
2772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2772 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2672 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2772 KB |
Output is correct |
9 |
Correct |
4 ms |
3052 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
3 ms |
2800 KB |
Output is correct |
12 |
Correct |
5 ms |
3412 KB |
Output is correct |
13 |
Correct |
5 ms |
3412 KB |
Output is correct |
14 |
Correct |
2 ms |
2664 KB |
Output is correct |
15 |
Correct |
2 ms |
2772 KB |
Output is correct |
16 |
Correct |
401 ms |
82824 KB |
Output is correct |
17 |
Correct |
68 ms |
17612 KB |
Output is correct |
18 |
Correct |
89 ms |
19992 KB |
Output is correct |
19 |
Correct |
535 ms |
89268 KB |
Output is correct |
20 |
Correct |
274 ms |
67964 KB |
Output is correct |
21 |
Correct |
34 ms |
9700 KB |
Output is correct |
22 |
Correct |
308 ms |
64008 KB |
Output is correct |