Problem:
Score : 600 points

Problem Statement

Given are N points (x_i, y_i) in a two-dimensional plane.

Find the minimum radius of a circle such that all the points are inside or on it.

Constraints

2 \leq N \leq 50

0 \leq x_i \leq 1000

0 \leq y_i \leq 1000

The given N points are all different.

The values in input are all integers.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
:
x_N y_N

Output

Print the minimum radius of a circle such that all the N points are inside or on it.

Your output will be considered correct if the absolute or relative error from our answer is at most 10^{-6}.

Sample Input 1

2
0 0
1 0

Sample Output 1

0.500000000000000000

Both points are contained in the circle centered at (0.5,0) with a radius of 0.5.

Sample Input 2

3
0 0
0 1
1 0

Sample Output 2

0.707106781186497524

Sample Input 3

10
10 9
5 9
2 0
0 0
2 7
3 3
2 5
10 0
3 7
1 9

Sample Output 3

6.726812023536805158

If the absolute or relative error from our answer is at most 10^{-6}, the output will be considered correct.

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>

using namespace std;

bool center3(const pair<double, double>& p1,
             const pair<double, double>& p2,
             const pair<double, double>& p3,
             pair<double, double>& center,
             double& r2) {
  double ax = (p1.first + p2.first) / 2;
  double ay = (p1.second + p2.second) / 2;
  double ux = (p1.second - p2.second);
  double uy = (p2.first - p1.first);
  double bx = (p2.first + p3.first) / 2;
  double by = (p2.second + p3.second) / 2;
  double vx = (p2.second - p3.second);
  double vy = (p3.first - p2.first);
  double dx = ax - bx;
  double dy = ay - by;
  double vu = vx * uy - vy * ux;
  if (vu == 0)
    return false;
  double g = (dx * uy - dy * ux) / vu;
  center = {
      bx + g * vx,
      by + g * vy,
  };
  auto ddx = p1.first - center.first;
  auto ddy = p1.second - center.second;
  r2 = ddx * ddx + ddy * ddy;
  return true;
}

vector<pair<double, double>> points;

bool contains_all(const pair<double, double>& c, double r2) {
  for (auto&& p : points) {
    auto dx = p.first - c.first;
    auto dy = p.second - c.second;
    if (r2 < dx * dx + dy * dy) {
      return false;
    }
  }
  return true;
}

void solve() {
  int n;
  cin >> n;
  points.reserve(n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    points.emplace_back(x, y);
  }
  double min_r2 = (double)INT_MAX;

  for (size_t i = 0; i + 1 < points.size(); ++i) {
    for (size_t j = i + 1; j < points.size(); ++j) {
      auto cx = (points[i].first + points[j].first) / 2.;
      auto cy = (points[i].second + points[j].second) / 2.;
      auto dx = points[i].first - cx;
      auto dy = points[i].second - cy;
      auto r2 = dx * dx + dy * dy;
      if (r2 < min_r2 && contains_all({cx, cy}, r2)) {
        min_r2 = r2;
      }
    }
  }

  for (size_t i = 0; i + 2 < points.size(); ++i) {
    for (size_t j = i + 1; j + 1 < points.size(); ++j) {
      for (size_t k = j + 1; k < points.size(); ++k) {
        pair<double, double> c;
        double r2;
        if (center3(points[i], points[j], points[k], c, r2) && r2 < min_r2 &&
            contains_all(c, r2)) {
          min_r2 = r2;
        }
      }
    }
  }

  cout << setprecision(15) << sqrt(min_r2) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}