#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
vector<vector<pii>> adj;
vector<bool> vis;
vector<int> dist;
const int INF = 1e9 +2;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
adj.resize(N);
vis.resize(N);
dist.resize(N, INF);
for(int i = 0; i<M; i++){
adj[R[i][0]].push_back(pii(R[i][1], L[i]));
adj[R[i][1]].push_back(pii(R[i][0], L[i]));
}
priority_queue<pii> pq;
for(int i = 0; i<K; i++){
pq.push(pii(0, P[i]));
vis[P[i]] =true;
}
while(pq.size()>0){
auto cur = pq.top();
pq.pop();
int cur_id = cur.second;
int cur_dist = -cur.first;
//cout<<cur_id<<" "<<cur_dist<<endl;
if(!vis[cur_id]){
vis[cur_id] = true;
}
else{
if(dist[cur_id]>cur_dist){
dist[cur_id] = cur_dist;
for(auto e: adj[cur_id]){
if(dist[e.first]>cur_dist + e.second){
pq.push(pii(-cur_dist - e.second, e.first));
}
}
}
}
}
return(dist[0]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 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 |
4492 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 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 |
4492 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
3 ms |
4696 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
2 ms |
4444 KB |
Output is correct |
12 |
Correct |
4 ms |
4956 KB |
Output is correct |
13 |
Correct |
4 ms |
5072 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 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 |
4492 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
3 ms |
4696 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
2 ms |
4444 KB |
Output is correct |
12 |
Correct |
4 ms |
4956 KB |
Output is correct |
13 |
Correct |
4 ms |
5072 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4568 KB |
Output is correct |
16 |
Correct |
433 ms |
64876 KB |
Output is correct |
17 |
Correct |
56 ms |
15184 KB |
Output is correct |
18 |
Correct |
71 ms |
16468 KB |
Output is correct |
19 |
Correct |
496 ms |
69424 KB |
Output is correct |
20 |
Correct |
324 ms |
56800 KB |
Output is correct |
21 |
Correct |
29 ms |
9044 KB |
Output is correct |
22 |
Correct |
335 ms |
46420 KB |
Output is correct |