#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;
void dfs(int nod, int p){
for(pi i: g[nod]){
if(i.x!=p) dfs(i.x, nod);
}
int mn[2];
mn[0]=mn[1]=1000000001;
if(t[nod]==1000000001){
for(pi i: g[nod]){
if(i.x!=p){
int xd=t[i.x]+i.y;
for(int id=0; id<2; id++) if(mn[id]>xd) swap(xd, mn[id]);
}
}
t[nod]=mn[1];
}
}
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]});
}
for(int i=0; i<k; i++) pq.push({0, p[i]}), viz[i]=1;
while(!pq.empty()){
int nod=pq.top().y, cost=pq.top().x;
pq.pop();
if(viz[nod]==0) viz[nod]++;
else{
viz[nod]++;
if(nod==0) 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:52:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
2680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
2680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
2680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |