# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
745971 |
2023-05-21T10:15:15 Z |
vjudge1 |
Cities (BOI16_cities) |
C++17 |
|
0 ms |
0 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
using ll = long long;
struct edge {
ll to;
ll w;
bool operator<(const edge& e)const {
return w > e.w;
}
};
const ll maxn = 100001;
vector<edge> g[maxn];
void dijkstra(ll a, vector<ll>& da) {
priority_queue<edge> q;
q.push({ a, 0 });
da[a] = 0;
while (!q.empty()) {
edge e = q.top();
q.pop();
if (da[e.to] < e.w)continue;
for (edge i : g[e.to]) {
if (da[i.to] < 0 || da[i.to] > da[e.to] + i.w) {
da[i.to] = da[e.to] + i.w;
q.push({ i.to, da[i.to] });
}
}
}
return;
}
int main()
{
ll n, k, m;
cin >> n >> k >> m;
ll a, b, c;
cin >> a >> b >> c;
for (ll i = 0; i < m; i++) {
ll a, b;
ll w;
cin >> a >> b >> w;
g[a].push_back({ b, w });
g[b].push_back({ a, w });
}
vector<ll> da(n + 1, -1), db(n + 1, -1), dc(n + 1, -1);
dijkstra(a, da);
dijkstra(b, db);
dijkstra(c, dc);
ll ans = ll64_MAX;
for (ll i = 1; i <= n; i++) {
ans = min(ans, da[i] + db[i] + dc[i]);
}
cout << ans << endl;
}
Compilation message
cities.cpp: In function 'int main()':
cities.cpp:56:11: error: 'll64_MAX' was not declared in this scope; did you mean 'INT64_MAX'?
56 | ll ans = ll64_MAX;
| ^~~~~~~~
| INT64_MAX