#include <bits/stdc++.h>
#include "crocodile.h"
#define ll long long
#define ii pair< ll , int >
#define se second
#define fi first
using namespace std;
const int N=1e5+55;
vector < pair < int , int > > vec[N];
priority_queue < ii , vector <ii> , greater<ii> >pq;
ll dist[N];
int cnt[N];
int n;
void dijk()
{
int v,u;
long long l,c;
while(pq.size())
{
c=pq.top().fi;
u=pq.top().fi;
pq.pop();
cnt[u]++;
if(cnt[u]!=2)
continue ;
dist[u]=c;
for(int i=0;i<vec[u].size();i++)
{
v=vec[u][i].se;
l=vec[u][i].fi;
if(l+c<dist[v])
pq.push({l+c,v});
}
}
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
n=N;
for(int i=0;i<N;i++)
dist[i]=1e17;
for(int i=0;i<K;i++)
{
dist[P[i]]=0;
pq.push({0,P[i]});
}
for(int i=0;i<M;i++)
{
vec[R[i][0]].push_back({L[i],R[i][1]});
vec[R[i][1]].push_back({L[i],R[i][0]});
}
dijk();
return dist[0];
}
Compilation message
crocodile.cpp: In function 'void dijk()':
crocodile.cpp:30:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<vec[u].size();i++)
~^~~~~~~~~~~~~~
# |
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 |
- |