#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
using lol=long long int;
const lol inf=1e18+8;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
vector<vector<pair<int,lol> > > 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<lol,int>,vector<pair<lol,int> >,greater<pair<lol,int> > > pq;
vector<lol> mn(N,inf);
vector<lol> smn(N,inf);
for(int i=0;i<K;i++)
{
pq.push({0,P[i]});
mn[P[i]]=smn[P[i]]=0;
}
while(!pq.empty())
{
auto [dist,u]=pq.top();
pq.pop();
if(dist>smn[u]) continue;
for(auto [v,w]:g[u])
{
lol nxt=min(inf,w+dist);
if(nxt<=mn[v] && mn[v]<smn[v])
{
smn[v]=min(inf,mn[v]);
mn[v]=min(inf,nxt);
pq.push({smn[v],v});
}else if(nxt<smn[v])
{
smn[v]=min(inf,nxt);
pq.push({smn[v],v});
}
}
}
return smn[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |