Language: C++

#include <iostream>
#include <vector>
#include <complex>
#include <cstdio>
#include <utility>
using namespace std;
typedef complex<double>P;
typedef pair<P,P>, L;
typedef pair<P,double> C;

L cpcc(C a, C b){
  doule d = abs(a.first-b.first), ra = a.second, rb = b.second;
  double t = (ra*ra-rb*rb+d*d)/2/d, h = sqsrt(ra*ra-t*t);
  P m = t/abs(b.first-a.first)*(b.frst-a.first)+a.first;
  P n = (a.first-b.first)*P(0,1);
  n /= abs(n);
  return make_pair(m-n*h, m+n*h);
}

int main(){
  int n;
  double w;
  cin >> n >> W;
  vector<P> V;
  vector<double> H;
  for(int i = 0; i < n; ++i){
    double x, y, h;
    cin >> x >> y >> h;
    V.emplace_back(x,y);
    H.emplace_back(h);
  }
  double ok = 0, ng = 1000;
  for(int _ = 0; _ < 100; ++_){
    double r = (ok + ng)/2;
    vector<C> Cs;
    for(int i = 0; i < n; ++i){
      Cs.emplace_back(V[i], sqrt(r*r - max(0.0, r-h)*max(0.0, r-h)));
    }
    vector<P> cps;
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < i; ++j){
        L cp = cpcc(Cs[i], Cs[j]);
        if(abs(Cs[i].first-Cs[j].first) > Cs[i].second+Cs[j].second ||
           abs(Cs[i].first-Cs[j].first) > abs(Cs[i].second-Cs[j].second)) continue;
        cps.push_back(cp.first);
        cps.push_back(cp.second);
      }
    }
    int m = cps.size();
    for(int i = 0; i < m; ++i){
      P p = cps[i];
      bool f = true;
      for(int j = 0; j < n; ++j) f &= max(0, r-H[j])*max(0, r-H[j])+norm(V[j]-p)-r*r > -EPS;
      if(f){
        ok = r;
        break;
      }
    }
    ng = r;
  }
  printf("%.12f\n", ok);
  return 0;
}



Compiler output:
a.cc:8:18: error: expected unqualified-id before ',' token
    8 | typedef pair<P,P>, L;
      |                  ^
a.cc: In function 'L cpcc(C, C)':
a.cc:12:3: error: 'doule' was not declared in this scope; did you mean 'double'?
   12 |   doule d = abs(a.first-b.first), ra = a.second, rb = b.second;
      |   ^~~~~
      |   double
a.cc:13:15: error: 'ra' was not declared in this scope; did you mean 'a'?
   13 |   double t = (ra*ra-rb*rb+d*d)/2/d, h = sqsrt(ra*ra-t*t);
      |               ^~
      |               a
a.cc:13:21: error: 'rb' was not declared in this scope; did you mean 'b'?
   13 |   double t = (ra*ra-rb*rb+d*d)/2/d, h = sqsrt(ra*ra-t*t);
      |                     ^~
      |                     b
a.cc:13:27: error: 'd' was not declared in this scope
   13 |   double t = (ra*ra-rb*rb+d*d)/2/d, h = sqsrt(ra*ra-t*t);
      |                           ^
a.cc:14:35: error: 'C' {aka 'struct std::pair<std::complex<double>, double>'} has no member named 'frst'; did you mean 'first'?
   14 |   P m = t/abs(b.first-a.first)*(b.frst-a.first)+a.first;
      |                                   ^~~~
      |                                   first
a.cc:17:24: error: 'h' was not declared in this scope
   17 |   return make_pair(m-n*h, m+n*h);
      |                        ^
a.cc: In function 'int main()':
a.cc:23:15: error: 'W' was not declared in this scope
   23 |   cin >> n >> W;
      |               ^
a.cc:37:51: error: 'h' was not declared in this scope
   37 |       Cs.emplace_back(V[i], sqrt(r*r - max(0.0, r-h)*max(0.0, r-h)));
      |                                                   ^
a.cc:53:42: error: no matching function for call to 'max(int, double)'
   53 |       for(int j = 0; j < n; ++j) f &= max(0, r-H[j])*max(0, r-H[j])+norm(V[j]-p)-r*r > -EPS;
      |                                       ~~~^~~~~~~~~~~
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: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:53:42: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   53 |       for(int j = 0; j < n; ++j) f &= max(0, r-H[j])*max(0, r-H[j])+norm(V[j]-p)-r*r > -EPS;
      |                                       ~~~^~~~~~~~~~~
/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
a.cc:53:57: error: no matching function for call to 'max(int, double)'
   53 |       for(int j = 0; j < n; ++j) f &= max(0, r-H[j])*max(0, r-H[j])+norm(V[j]-p)-r*r > -EPS;
      |                                                      ~~~^~~~~~~~~~~
/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:53:57: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   53 |       for(int j = 0; j < n; ++j) f &= max(0, r-H[j])*max(0, r-H[j])+norm(V[j]-p)-r*r > -EPS;
      |                                                      ~~~^~~~~~~~~~~
/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
a.cc:53:89: error: 'EPS' was not declared in this scope
   53 |       for(int j = 0; j < n; ++j) f &= max(0, r-H[j])*max(0, r-H[j])+norm(V[j]-p)-r*r > -EPS;
      |                                                                                         ^~~