#include<bits/stdc++.h>
#include<crocodile.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
const ll mod = 998244353;
vector <pi> g[100001];
int t[100001], viz[100001];
priority_queue<pi, vector<pi>, greater<pi>> pq;
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
for(int i=0; i<n; i++) t[i]=1000000001;
for(int i=0; i<k; i++) t[p[i]]=0;
for(int i=0; i<m; i++){
g[r[i][0]].pb({r[i][1], l[i]});
g[r[i][1]].pb({r[i][0], l[i]});
}
fill(viz, viz+n, 0);
for(int i=0; i<k; i++) pq.push({0, p[i]}), viz[p[i]]=1;
while(!pq.empty()){
int nod=pq.top().y, cost=pq.top().x;
//cout<<nod<<" "<<cost<<"\n";
pq.pop();
if(viz[nod]==0) viz[nod]++;
else if(viz[nod]==1){
viz[nod]++;
if(nod==2) return cost;
for(pi i: g[nod]) pq.push({cost+i.y, i.x});
}
}
}
Compilation message
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Incorrect |
4 ms |
2680 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Incorrect |
4 ms |
2680 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Incorrect |
4 ms |
2680 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |