#include <bits/stdc++.h>
//#include "factories.h"
//#include "crocodile.h"
#define f first
#define s second
using namespace std;
const int maxn = 1e5 + 69;
set<pair<int, int>> g[maxn];
vector<int> cnt(maxn), par(maxn, -1), d(maxn, 1e9);
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for(int i = 0;i < M;i++) {
g[R[i][0]].insert({L[i], R[i][1]});
g[R[i][1]].insert({L[i], R[i][0]});
}
for(int i = 0;i < K;i++)
cnt[P[i]] = 1;
for(int i = 1;i < N;i++) {
if(cnt[i])
continue;
if(g[i].size() <= 2 && !cnt[i]) {
for(auto x : g[i])
g[x.s].erase({x.f, i});
g[i].clear();
}
}
// for(int i = 0;i < N;i++) {
// cout << i << endl;
// for(auto x : g[i]) {
// cout << x.f << " " << x.s << endl;
// }
// cout << endl;
// }
priority_queue<pair<int, int>> pq;
d[0] = 0;
pq.push({0, 0});
while(!pq.empty()) {
auto u = pq.top();
pq.pop();
auto x = *g[u.s].begin();
if(x.s == par[u.s])
g[u.s].erase(++g[u.s].begin());
else
g[u.s].erase(g[u.s].begin());
for(auto v : g[u.s]) {
if(d[v.s] <= d[u.s] + v.f)
continue;
d[v.s] = d[u.s] + v.f;
pq.push({-d[v.s], v.s});
}
}
int ans = 1e9;
for(int i = 1;i < N;i++) {
if(cnt[i])
ans = min(ans, d[i]);
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while(tt--) {
int n, m;
cin >> n >> m;
int r[m][2];
for(int i = 0;i < m;i++)
cin >> r[i][0] >> r[i][1];
int l[m];
for(int i = 0;i < m;i++)
cin >> l[i];
int k;
cin >> k;
int p[k];
for(int i = 0;i < k;i++)
cin >> p[i];
cout << travel_plan(n, m, r, l, k, p);
}
return 0;
}
Compilation message
/usr/bin/ld: /tmp/ccOJH6ft.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccXaYSVs.o:crocodile.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status