#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vb vector<bool>
#define vc vector<char>
#define vvc vector<vc>
#define vvb vector<vb>
#define si set<int>
#define mii map<int,int>
const int mod=1e9+7;
const int N=2e5+1;
const int LN=LLONG_MAX/10;
struct com{
bool operator()(pair<pii,int>& a,pair<pii,int>& b){
return a.second>b.second;
}
};
struct co{
bool operator()(pii& a,pii& b){
return a.second>b.second;
}
};
int travel_plan(int n,int m,int R[][2],int L[],int k,int P[]){
vvpii G(n);
for(int i=0;i<m;i++){
G[R[i][0]].push_back({R[i][1],L[i]});
G[R[i][1]].push_back({R[i][0],L[i]});
}
priority_queue<pair<pii,int>,vector<pair<pii,int>>,com> Q;
for(int i=0;i<k;i++){
Q.push({{P[i],P[i]},0});
}
vi bloq(n,LN);
while(Q.size()){
int u=Q.top().first.first;
int p=Q.top().first.second;
int wu=Q.top().second;
Q.pop();
if(bloq[u]!=LN)continue;
bloq[u]=p;
for(auto x : G[u]){
int v=x.first;
int wv=x.second;
if(bloq[v]==LN)Q.push({{v,u},wu+wv});
}
}
vi dist(n,LN);
priority_queue<pii,vpii,co> Q2;
Q2.push({0,0});
while(Q2.size()){
int u=Q2.top().first;
int wu=Q2.top().second;
Q2.pop();
if(dist[u]!=LN)continue;
dist[u]=wu;
for(auto x : G[u]){
int v=x.first;
int wv=x.second;
if(bloq[u]==v)continue;
if(dist[v]==LN)Q2.push({v,wu+wv});
}
}
int sol=LN;
for(int i=0;i<k;i++){
sol=min(sol,dist[P[i]]);
}
if(sol==LN)return -1;
return sol;
}
Compilation message
crocodile.cpp:17:23: warning: overflow in conversion from 'long long int' to 'int' changes value from '922337203685477580' to '-858993460' [-Woverflow]
17 | const int LN=LLONG_MAX/10;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |