#include "crocodile.h"
#include <vector>
#include <queue>
#include <stdint.h>
static std::vector<std::pair<int,int> > adj[100005];
static int vis[100005];
static int64_t dist[100005];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for(int i=0;i<M;i++){
adj[R[i][0]].push_back({R[i][1],L[i]});
adj[R[i][1]].push_back({R[i][0],L[i]});
}
std::priority_queue<std::pair<int64_t,int> > pq;
for(int i=0;i<K;i++){
pq.push({0,P[i]});
pq.push({0,P[i]});
}
while(!pq.empty()){
int64_t d=-pq.top().first;
int node=pq.top().second;
pq.pop();
if(++vis[node]!=2) continue;
dist[node]=d;
for(auto e:adj[node]){
int child=e.first;
pq.push({-dist[node]-e.second,child});
}
}
return dist[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2816 KB |
Output is correct |
2 |
Correct |
3 ms |
2688 KB |
Output is correct |
3 |
Correct |
4 ms |
2688 KB |
Output is correct |
4 |
Correct |
5 ms |
2816 KB |
Output is correct |
5 |
Correct |
5 ms |
2816 KB |
Output is correct |
6 |
Correct |
4 ms |
2816 KB |
Output is correct |
7 |
Correct |
5 ms |
2816 KB |
Output is correct |
8 |
Correct |
5 ms |
2816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2816 KB |
Output is correct |
2 |
Correct |
3 ms |
2688 KB |
Output is correct |
3 |
Correct |
4 ms |
2688 KB |
Output is correct |
4 |
Correct |
5 ms |
2816 KB |
Output is correct |
5 |
Correct |
5 ms |
2816 KB |
Output is correct |
6 |
Correct |
4 ms |
2816 KB |
Output is correct |
7 |
Correct |
5 ms |
2816 KB |
Output is correct |
8 |
Correct |
5 ms |
2816 KB |
Output is correct |
9 |
Correct |
7 ms |
3328 KB |
Output is correct |
10 |
Correct |
4 ms |
2688 KB |
Output is correct |
11 |
Correct |
5 ms |
2944 KB |
Output is correct |
12 |
Correct |
11 ms |
3840 KB |
Output is correct |
13 |
Correct |
10 ms |
3836 KB |
Output is correct |
14 |
Correct |
4 ms |
2688 KB |
Output is correct |
15 |
Correct |
6 ms |
2816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2816 KB |
Output is correct |
2 |
Correct |
3 ms |
2688 KB |
Output is correct |
3 |
Correct |
4 ms |
2688 KB |
Output is correct |
4 |
Correct |
5 ms |
2816 KB |
Output is correct |
5 |
Correct |
5 ms |
2816 KB |
Output is correct |
6 |
Correct |
4 ms |
2816 KB |
Output is correct |
7 |
Correct |
5 ms |
2816 KB |
Output is correct |
8 |
Correct |
5 ms |
2816 KB |
Output is correct |
9 |
Correct |
7 ms |
3328 KB |
Output is correct |
10 |
Correct |
4 ms |
2688 KB |
Output is correct |
11 |
Correct |
5 ms |
2944 KB |
Output is correct |
12 |
Correct |
11 ms |
3840 KB |
Output is correct |
13 |
Correct |
10 ms |
3836 KB |
Output is correct |
14 |
Correct |
4 ms |
2688 KB |
Output is correct |
15 |
Correct |
6 ms |
2816 KB |
Output is correct |
16 |
Correct |
1309 ms |
74472 KB |
Output is correct |
17 |
Correct |
93 ms |
12456 KB |
Output is correct |
18 |
Correct |
133 ms |
13944 KB |
Output is correct |
19 |
Correct |
1356 ms |
77564 KB |
Output is correct |
20 |
Correct |
782 ms |
71200 KB |
Output is correct |
21 |
Correct |
49 ms |
7800 KB |
Output is correct |
22 |
Correct |
590 ms |
34468 KB |
Output is correct |