#include <bits/stdc++.h>
using namespace std;
const int N = 110000;
long long const inf = 1e16;
int n, m, k;
pair<pair<int, int>, long long> edge[10 * N];
vector<pair<int, long long>> g[N];
vector<int> Exit;
int trace1[N], trace2[N];
long long min_dist1[N], min_dist2[N];
bool update(int x, int i, long long d) {
if (x == trace2[i]) {
if (min_dist2[i] <= d) {
return false;
}
min_dist2[i] = d;
if (min_dist1[i] > min_dist2[i]) {
swap(min_dist1[i], min_dist2[i]);
swap(trace1[i], trace2[i]);
}
return true;
}
if (x == trace1[i]) {
if (min_dist1[i] <= d) {
return false;
}
min_dist1[i] = d;
return true;
}
if (min_dist2[i] <= d) {
return false;
}
min_dist2[i] = d;
trace2[i] = x;
if (min_dist1[i] > min_dist2[i]) {
swap(min_dist1[i], min_dist2[i]);
swap(trace1[i], trace2[i]);
}
return true;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
int a, b;
for (int i = 0; i < m; i ++) {
cin >> edge[i].first.first >> edge[i].first.second;
}
for (int i = 0; i < m; i ++) {
cin >> edge[i].second;
}
for (int i = 0; i < m; i ++) {
g[edge[i].first.first].push_back({edge[i].first.second, edge[i].second});
g[edge[i].first.second].push_back({edge[i].first.first, edge[i].second});
}
cin >> k;
for (int i = 0; i < k; i ++) {
cin >> a;
Exit.push_back(a);
}
priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
for (int i = 0; i < n; i ++) {
min_dist1[i] = min_dist2[i] = inf;
trace1[i] = n;
trace2[i] = n;
}
for (int a : Exit) {
min_dist1[a] = min_dist2[a] = 0;
trace1[a] = a;
trace2[a] = a;
pq.push({0, a});
}
int x;
long long d;
while (!pq.empty()) {
auto [d, x] = pq.top();
pq.pop();
if (d > min_dist2[x]) continue;
for (pair<int, long long> e : g[x]) {
if (update(x, e.first, d + e.second)) {
if (min_dist2[e.first] < inf) {
pq.push({min_dist2[e.first], e.first});
}
}
}
}
cout << min_dist2[0];
return 0;
}
Compilation message
crocodile.cpp: In function 'int main()':
crocodile.cpp:101:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
101 | auto [d, x] = pq.top();
| ^
crocodile.cpp:60:12: warning: unused variable 'b' [-Wunused-variable]
60 | int a, b;
| ^
crocodile.cpp:97:9: warning: unused variable 'x' [-Wunused-variable]
97 | int x;
| ^
crocodile.cpp:98:15: warning: unused variable 'd' [-Wunused-variable]
98 | long long d;
| ^
/usr/bin/ld: /tmp/ccBTWxHR.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc302lIS.o:crocodile.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccBTWxHR.o: in function `main':
grader.cpp:(.text.startup+0x36): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status