#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<ll,ll>
#define f first
#define s second
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
ios::sync_with_stdio(false); cin.tie(0);
vector<vector<pii>> adj(n);
F0R(i,m) {
adj[r[i][0]].pb({r[i][1],l[i]});
adj[r[i][1]].pb({r[i][0],l[i]});
}
vector<pii> mn(n,{LLONG_MAX,LLONG_MAX});
priority_queue<pii,vector<pii>,greater<pii>> pq;
F0R(i,k) {
mn[p[i]] = {0,0};
pq.push({0,p[i]});
}
while (pq.size()) {
pii cur = pq.top(); pq.pop();
if (cur.f != mn[cur.s].s) {continue;}
for (pii qwerty : adj[cur.s]) {
int cand = qwerty.s+cur.f, x = qwerty.f;
//if (cur.s==2) {cout<<x;}
if (cand < mn[x].s) {
if (cand <= mn[x].f) {
mn[x].s = mn[x].f; mn[x].f = cand;
} else {mn[x].s = cand;}
pq.push({mn[x].s,x});
}
}
} cout << mn[0].s << '\n';
}
Compilation message
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:41:1: warning: no return statement in function returning non-void [-Wreturn-type]
41 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
9052 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
9052 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
9052 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |