Language: C++

#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
using namespace std;

inline double sq(double x) { return x * x; }

struct point {
    double x, y, z;
    point() {}
    point(double x, double y, double z): x(x), y(y), z(z) {}
    point operator + (const point& o) const { return point(x+o.x, y+o.y, z+o.z); }
    point operator - (const point& o) const { return point(x-o.x, y-o.y, z-o.z); }
    point operator * (const double a) const { return point(x*a,   y*a,   z*a); }
};

double fabs(point p) { return sqrt(sq(p.x) + sq(p.y) + sq(p.z)); }
double dist(point p, point q) { return fabs(p - q); }
double dot(point p, point q) { return p.x*q.x + p.y*q.y + p.z*q.z; }
point cross(point p, point q) {
    return point(
        p.y*q.z - p.z*q.y,
        p.z*q.x - p.x*q.z,
        p.x*q.y - p.y*q.x
    );
}

struct line {
    point a, b;
    line() {}
    line(point a, point b): a(a), b(b) {}
};

double dist_point_line(point p, line l) {
    if (dot(l.b - l.a, p - l.a) >= 0 && dot(l.a - l.b, p - l.b) >= 0) {
        point h = l.a + (l.b - l.a) * (dot(l.b - l.a, p - l.a) / sq(fabs(l.b - l.a)));
        return dist(p, h);
    }

    return min(dist(p, l.a), dist(p, l.b));
}

int N; double Sx, Sy, Ex, Ey;
vector<vector<point>> rects;
vector<line> vs;

double solve() {
    line c(point(Sx, Sy, 0), point(Ex, Ey, 0));
    for (vector<point> r : rects) {
        for (int i = 0; i < r.size(); ++i) {
            for (int j = i+1; j < r.size(); ++j) {
                double c1 = cross(c.b - c.a, r[i] - c.a).z * cross(c.b - c.a, r[j] - c.a).z;
                double c2 = cross(r[j] - r[i], c.a - r[i]).z * cross(r[j] - r[i], c.b - r[i]).z;
                if (c1 < 0 && c2 < 0) {
                    return 0;
                } else if (c1 * c2 == 0) {
                    double d1 = dist_point_line(r[i], c);  
                    double d2 = dist_point_line(r[j], c);  
                    double d3 = dist_point_line(c.a, line(r[i], r[j]));  
                    double d4 = dist_point_line(c.b, line(r[i], r[j]));  
                    if (fabs(min({d1, d2, d3, d4})) < 1e-8) {
                        return 0;
                    }
                }
            }
        }
    }

    double l = 0, r = 1050;
    for (int g = 0; g < 100; ++g) {
        double m = (l + r) / 2;

        line c(point(Sx, Sy, m), point(Ex, Ey, m));

        bool ok = true;
        for (line p : vs) {
            if (dist_point_line(p.a, c) <= m || dist_point_line(p.b, c) <= m)
                ok = false;
            if (dist_point_line(c.a, p) <= m || dist_point_line(c.b, p) <= m)
                ok = false;
            if (m < p.a.z) p.a.z = p.b.z = m;
            if (dist_point_line(p.a, c) <= m || dist_point_line(p.b, c) <= m)
                ok = false;
            if (dist_point_line(c.a, p) <= m || dist_point_line(c.b, p) <= m)
                ok = false;
        }

        (ok ? l : r) = m;
    }

    return (l + r) / 2;
}

int main(void) {
    cout << fixed << setprecision(4);
    while (true) {
        cin >> N; if (N == 0) break;
        cin >> Sx >> Sy >> Ex >> Ey;
        vs.clear();
        rects.clear();
        for (int i = 0; i < N; ++i) {
            double minx, miny, maxx, maxy, h;
            cin >> minx >> miny >> maxx >> maxy >> h;
            vs.emplace_back(point(minx, miny, h), point(minx, maxy, h));
            vs.emplace_back(point(minx, miny, h), point(maxx, miny, h));
            vs.emplace_back(point(minx, maxy, h), point(maxx, maxy, h));
            vs.emplace_back(point(maxx, miny, h), point(maxx, maxy, h));

            vector<point> vv;
            vv.emplace_back(minx, miny, h);
            vv.emplace_back(minx, maxy, h);
            vv.emplace_back(maxx, miny, h);
            vv.emplace_back(maxx, maxy, h);
            rects.push_back(vv);
        }
        cout << solve() << endl;
    }
    return 0;
}



Compiler output:
a.cc: In function 'double solve()':
a.cc:62:33: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   62 |                     if (fabs(min({d1, d2, d3, d4})) < 1e-8) {
      |                              ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided