#include "crocodile.h"
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#define ll long long
using namespace std;
vector <array<ll, 2> > adj[100000];
priority_queue <array<ll, 2>, vector<array<ll, 2>>, greater<array<ll,2>>> pq;
ll dist[100000], in[100000], MN[2][100000];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for (int i=0; i<N; ++i) dist[i] = MN[0][i] = MN[1][i] = 1e18;
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<K; ++i) {
dist[P[i]] = 0;
pq.push({0, P[i]});
}
cout << dfs(0, -1) << endl;
while (!pq.empty()) {
auto [w, u] = pq.top();
pq.pop();
if (dist[u] != w) continue;
for (auto [v, x] : adj[u]) {
if (dist[v] > dist[u]+x) {
++in[v];
if (in[v] == 1) MN[0][v] = dist[u]+x;
else if (in[v] == 2) {
MN[1][v] = max(MN[0][v], dist[u]+x);
MN[0][v] = min(MN[0][v], dist[u]+x);
dist[v] = MN[1][v];
pq.push({dist[v], v});
}
else {
if (MN[0][v] > dist[u]+x) {
MN[1][v] = MN[0][v];
MN[0][v] = dist[u]+x;
dist[v] = MN[1][v];
pq.push({dist[v], v});
}
else if (MN[1][v] > dist[u]+x) {
MN[1][v] = dist[u]+x;
dist[v] = MN[1][v];
pq.push({dist[v], v});
}
}
}
}
}
return dist[0];
}
Compilation message
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:25:11: error: 'dfs' was not declared in this scope
25 | cout << dfs(0, -1) << endl;
| ^~~
crocodile.cpp:27:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
27 | auto [w, u] = pq.top();
| ^
crocodile.cpp:30:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
30 | for (auto [v, x] : adj[u]) {
| ^