Language: C++

#include <algorithm>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
lli MOD = 1000000007;
struct P {
    complex<double> p;
    double r;
    P(double a, double b, double c)
    {
        p = complex<double>(a, b);
        r = c;
    }
};
#define UF_MAX 1005
struct UFind {
    int par[UF_MAX];
    int rank[UF_MAX];
    int count[UF_MAX];
    UFind(int n)
    {
        rep(i, n)
        {
            par[i] = i;
            rank[i] = 0;
            count[i] = 1;
        }
    }
    int find(int x)
    {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            count[y] += count[x];
        } else {
            par[y] = x;
            count[x] += count[y];
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};
int main()
{
    double a, b, c, cc;
    cin >> a >> b >> c >> cc;

    complex<double> s = complex<double>(a, b), t = complex<double>(c, cc);
    int n;
    cin >> n;
    vector<P> d;
    vector<pair<int, double>> e[1005];
    rep(i, n)
    {
        cin >> a >> b >> c;
        d.push_back(P(a, b, c));
    }
    d.push_back(P(s.real(), s.imag(), 0));
    d.push_back(P(t.real(), t.imag(), 0));

    UFind uf(n + 2);
    rep(i, n + 2) rep(j, n + 2)
    {
        if (j == i)
            continue;
        double dis = max(0.0, sqrt(norm(d[i].p - d[j].p)) - d[i].r - d[j].r);
        e[i].push_back(make_pair(j, dis));
        e[j].push_back(make_pair(i, dis));
        if (dis == 0.0) {
            uf.unite(i, j);
        }
    }
    //    priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> que;
    double ed[1005][1005];
    rep(i, 1005) rep(j, 1005) ed[i][j] = -1;
    rep(i, n + 2)
    {
        int par = uf.find(i);
        rep(j, e[i].size())
        {
            int to = e[i][j].first;
            double dd = e[i][j].second;
            if (uf.find(to) == par)
                continue;
            if (dd == 0.0)
                continue;
            if (ed[uf.find(to)][uf.find(par)] == -1) {
                ed[uf.find(to)][uf.find(par)] = dd;
                ed[uf.find(par)][uf.find(to)] = dd;
            } else if (ed[uf.find(to)][uf.find(par)] > dd) {
                ed[uf.find(to)][uf.find(par)] = dd;
                ed[uf.find(par)][uf.find(to)] = dd;
            }
        }
    }
    priority_queue<pair<double, int>, vector<pair<double, int>>> que;

    double di[1010];
    rep(i, 1010) di[i] = -1;
    que.push(make_pair(0.0, n));
    set<int> kouho;
    rep(i, n + 2) kouho.insert(uf.find(i));
    int cnt = 0;
    while (!que.empty()) {
        if (cnt >= max(n * n, 1e7))
            break;
        cnt++;
        pair<double, int> cur = que.top();
        que.pop();
        int now = cur.second;
        double nd = cur.first;
        if (di[uf.find(now)] < nd && di[uf.find(now)] != -1)
            continue;
        di[uf.find(now)] = nd;
        if (uf.same(now, n + 1))
            break;
        bool used[1005] = {};
        for (auto to : kouho) {
            if (ed[uf.find(now)][uf.find(to)] == -1)
                continue;
            if (!used[uf.find(to)] && (di[uf.find(to)] == -1 || di[uf.find(to)] > nd + ed[uf.find(now)][uf.find(to)])) {
                used[uf.find(to)] = true;
                que.push(make_pair(nd + ed[uf.find(now)][uf.find(to)], uf.find(to)));
            }
        }
    }
    printf("%.10f\n", di[uf.find(n + 1)]);
    //cout << di[n + 1] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:128:23: error: no matching function for call to 'max(int, double)'
  128 |         if (cnt >= max(n * n, 1e7))
      |                    ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:128:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
  128 |         if (cnt >= max(n * n, 1e7))
      |                    ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:128:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  128 |         if (cnt >= max(n * n, 1e7))
      |                    ~~~^~~~~~~~~~~~