#include <bits/stdc++.h>
using namespace std;
const int N=1e5+1;
struct nod
{
int unde;
long long cost;
};
struct coada
{
int unde;
long long cost;
};
struct compare
{
bool operator()(coada &x,coada &y)
{
return x.cost>y.cost;
}
};
vector<nod>adj[N];
long long best[N][2];
int travel_plan(int n,int m,int r[][2],int l[],int k,int p[])
{
for(int i=0;i<m;i++)
{
adj[r[i][0]].push_back({r[i][1],l[i]});
adj[r[i][1]].push_back({r[i][0],l[i]});
}
for(int i=0;i<n;i++)
{
best[i][0]=best[i][1]=1e11;
}
priority_queue<coada,vector<coada>,compare>pq;
for(int i=0;i<k;i++)
{
best[p[i]][0]=best[p[i]][1]=0;
pq.push({p[i],0});
}
while(!pq.empty())
{
int nod=pq.top().unde;
long long cost=pq.top().cost;
pq.pop();
for(auto u:adj[nod])
{
if(best[u.unde][0]>cost+u.cost)
{
best[u.unde][1]=best[u.unde][0];
best[u.unde][0]=cost+u.cost;
pq.push({u.unde,best[u.unde][1]});
}
else
if(best[u.unde][1]>cost+u.cost)
{
best[u.unde][1]=cost+u.cost;
pq.push({u.unde,best[u.unde][1]});
}
}
}
return best[0][1];
}
int a[N][2],p[N],n,m,k,c[N];
int main()
{
cin>>n>>m>>k;
for(int i=0;i<m;i++)
cin>>a[i][0]>>a[i][1];
for(int i=0;i<m;i++)
cin>>c[i];
for(int i=0;i<k;i++)
cin>>p[i];
cout<<travel_plan(n,m,a,c,k,p);
return 0;
}
Compilation message
crocodile.cpp: In function 'int main()':
crocodile.cpp:77:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
77 | for(int i=0;i<k;i++)
| ^~~
crocodile.cpp:80:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
80 | cout<<travel_plan(n,m,a,c,k,p);
| ^~~~
/usr/bin/ld: /tmp/ccXoBJK0.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccm7jIcZ.o:crocodile.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status