#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define ss second
#define ff first
typedef long long ll;
// #define int ll
int mod = 1e9+7;
int inf = 1e18;
int travel_plan(int N, int M, int R[][2],
int L[], int k, int p[]){
int n = N, m = M;
vector<vector<pair<int,int>>> adj(n);
for(int i = 0; i < m; ++i){
int a = R[i][0],b = R[i][1],c = L[i];
adj[a].push_back({b,c});
adj[b].push_back({a,c});
}
set<int> exit;
for(int i = 0; i < k; ++i){
exit.insert(p[i]);
}
priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;
vector<int> dis(n, 1e10);
int ans = 1e10;
dis[0] = 0;
pq.push({0,0});
bool pass = 0;
while(!pq.empty()){
pair<int,int> a = pq.top(); pq.pop();
if(dis[a.ss]!=a.ff){
continue;
}
if(exit.find(a.ss)!=exit.end()){
ans = min(ans, a.ff);
}
pass = false;
for(auto &[nxt, w] : adj[a.ss]){
if(a.ff+w<nxt&&pass){
pq.push({a.ff+w,nxt});
}else if(a.ff+w>=nxt){
continue;
}
pass = true;
}
}
return ans;
}
// signed main(){
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
// // ifstream cin ("shortcut.in");
// // ofstream cout ("shortcut.out");
// return 0;
// }
Compilation message
crocodile.cpp:9:11: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
9 | int inf = 1e18;
| ^~~~
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:25:24: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '1.0e+10' to '2147483647' [-Woverflow]
25 | vector<int> dis(n, 1e10);
| ^~~~
crocodile.cpp:26:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+10' to '2147483647' [-Woverflow]
26 | int ans = 1e10;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |