Language: C++

#include <bits/stdc++.h>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;

constexpr long double INF = 1e10;
constexpr int MAX_N = 2000;

vector<long double> d(MAX_N, INF);
priority_queue<pair<long double, ll>, vector<pair<long double, ll>>, greater<pair<long double, ll>>> que;
vector<vector<pair<ll, long double>>> edges(MAX_N);

struct Point {
    Pll pos;
    long double r;
    Point(ll x=0, ll y=0, long double r=0.0): r(r) {
        pos = {x, y};
    }
    Point operator - (const Point &p) const { return Point(pos.first-p.pos.first, pos.second-p.pos.second); }
    long double abs() const { return sqrt(norm()); }
    long double norm() const { return pos.first*pos.first + pos.second*pos.second; }
    long double dot(Point &p) const { return pos.first*p.pos.first + pos.second*p.pos.second; }
};

void dijkstra(ll start){
    d[start] = 0;
    que.push({0, start});

    while(!que.empty()){
        auto v = que.top(); que.pop();
        if(d[v.second] < v.first) continue;
        for(auto e: edges[v.second]){
            if(d[e.first] > d[v.second] + e.second){
                d[e.first] = d[v.second] + e.second;
                que.push({d[e.first], e.first});
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    Point s, t;
    cin >> s.pos.first >> s.pos.second >> t.pos.first >> t.pos.second;
    int n;
    cin >> n;
    vector<Point> points(n);
    for(int i=0;i<n;++i){
        cin >> points[i].pos.first >> points[i].pos.second >> points[i].r;
    }

    for(int i=0;i<n;++i) {
        for(int j=i+1;j<n;++j) {
            long double dist = max(0.0, (points[i]-points[j]).abs() - points[i].r - points[j].r);
            edges[i].emplace_back(j, dist);
            edges[j].emplace_back(i, dist);
        }
        edges[n].emplace_back(i, max(0.0, (points[i]-s).abs() - points[i].r));
        edges[i].emplace_back(n+1, max(0.0, (points[i]-t).abs() - points[i].r));
    }

    dijkstra(n);

    cout << fixed << setprecision(15) << d[n+1] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:35: error: no matching function for call to 'max(double, long double)'
   56 |             long double dist = max(0.0, (points[i]-points[j]).abs() - points[i].r - points[j].r);
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 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:56:35: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'long double')
   56 |             long double dist = max(0.0, (points[i]-points[j]).abs() - points[i].r - points[j].r);
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:56:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   56 |             long double dist = max(0.0, (points[i]-points[j]).abs() - points[i].r - points[j].r);
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:37: error: no matching function for call to 'max(double, long double)'
   60 |         edges[n].emplace_back(i, max(0.0, (points[i]-s).abs() - points[i].r));
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:60:37: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'long double')
   60 |         edges[n].emplace_back(i, max(0.0, (points[i]-s).abs() - points[i].r));
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
/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:60:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   60 |         edges[n].emplace_back(i, max(0.0, (points[i]-s).abs() - points[i].r));
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:61:39: error: no matching function for call to 'max(double, long double)'
   61 |         edges[i].emplace_back(n+1, max(0.0, (points[i]-t).abs() - points[i].r));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:61:39: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'long double')
   61 |         edges[i].emplace_back(n+1, max(0.0, (points[i]-t).abs() - points[i].r));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
/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:61:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   61 |         edges[i].emplace_back(n+1, max(0.0, (points[i]-t).abs() - points[i].r));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~