#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector <vector <pair <int, int>>> adj;
int N;
pair <int, ll> dijkstra(int s) {
priority_queue <pair <ll, int>> pq;
vector <ll> dis(N+1, 1e17);
vector <bool> processed(N+1);
dis[s] = 0;
pq.push({0, s});
int node = 0l
ll mx = 0;
while (!pq.empty()) {
s = pq.top().second;
pq.pop();
if (processed[s])
continue;
processed[s] = true;
if (mx < dis[s]) {
mx = dis[s];
node = s;
}
for (auto i : adj[s]) {
if (dis[i.first] > dis[s] + i.second) {
dis[i.first] = dis[s] + i.second;
pq.push({-dis[i.first], i.first});
}
}
}
return {node, mx};
}
long long find_shortcut(int n, vector<int> l, vector<int> d, int c)
{
adj.resize(n * 2 + 5);
for (int i = 0; i+1 < n; i++) {
adj[i].push_back({i+1, l[i]});
adj[i+1].push_back({i, l[i]});
}
int ogn = n;
for (int i = 0; i < ogn; i++) {
if (d[i] == 0)
continue;
adj[i].push_back({n, d[i]});
adj[n].push_back({i, d[i]});
n++;
}
N = n;
pair <int, ll> res = dijkstra(0);
res = dijkstra(res.first);
ll ans = res.second;
for (int i = 0; i < ogn; i++) {
for (int j = i+1; j < ogn; j++) {
adj[i].push_back({j, c});
adj[j].push_back({i, c});
res = dijkstra(0);
res = dijkstra(res.first);
ans = min(ans, res.second);
adj[i].pop_back();
adj[j].pop_back();
}
}
return ans;
}
// int main() {
// int n;
// cin >> n;
// vector <int> l(n), d(n);
// for (int i = 0; i < n-1; i++)
// cin >> l[i];
// for (int i = 0; i < n; i++)
// cin >> d[i];
// int c;
// cin >> c;
// cout << find_shortcut(n, l, d, c) << '\n';
// }
Compilation message
shortcut.cpp: In function 'std::pair<int, long long int> dijkstra(int)':
shortcut.cpp:14:5: error: expected ',' or ';' before 'll'
14 | ll mx = 0;
| ^~
shortcut.cpp:21:13: error: 'mx' was not declared in this scope
21 | if (mx < dis[s]) {
| ^~
shortcut.cpp:32:19: error: 'mx' was not declared in this scope
32 | return {node, mx};
| ^~
shortcut.cpp:32:21: error: could not convert '{node, <expression error>}' from '<brace-enclosed initializer list>' to 'std::pair<int, long long int>'
32 | return {node, mx};
| ^
| |
| <brace-enclosed initializer list>