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 <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

double delta = 1e-9;

int main(){
  long long int N;
  double tmp1, tmp2;
  scanf("%lld", &N);

  std::vector<double> x, y;
  for(long long int i = 0; i < N; i++){
    scanf("%lf%lf", &tmp1, &tmp2);
    x.push_back(tmp1);
    y.push_back(tmp2);
  }


  if(N==2){
    std::cerr << "Answer: " << std::endl;
    std::cout << std::sqrt((x[0]-x[1])*(x[0]-x[1]) + (y[0]-x[1])*(y[0]-y[1]))*0.5 << std::endl;
    return 0;
  }

  double lij, ljk, lki;
  double a, b, c, d, e, f;
  double aa, bb, cc, dd, ee, ff;
  double r, px, py;
  long long int flg = 0;
  double ans = 1.0e9;
  for(long long int i = 0; i < N; i++){
    for(long long int j = i+1; j < N; j++){
      for(long long int k = j+1; k < N; k++){
        lij = ((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
        ljk = ((x[j]-x[k])*(x[j]-x[k]) + (y[j]-y[k])*(y[j]-y[k]));
        lki = ((x[k]-x[i])*(x[k]-x[i]) + (y[k]-y[i])*(y[k]-y[i]));

        /*if(lij > ljk+lki){
          px = 0.5 * (x[i]+x[j]);
          py = 0.5 * (y[i]+y[j]);
          r = std::sqrt(lij)*0.5;
        }
        else if(ljk > lij+lki){
          px = 0.5 * (x[k]+x[j]);
          py = 0.5 * (y[k]+y[j]);
          r = std::sqrt(ljk)*0.5;
        }
        else if(lki > lij + ljk){
          px = 0.5 * (x[k]+x[i]);
          py = 0.5 * (y[k]+y[i]);
          r = std::sqrt(lki)*0.5;
        }
        else*/{
        
        a = x[i];
        b = y[i];
        c = x[j];
        d = y[j];
        e = x[k];
        f = y[k];
        aa = a * a;
        bb = b * b;
        cc = c * c;
        dd = d * d;
        ee = e * e;
        ff = f * f;

        py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f));

        if(std::abs(c-a) < 0.5){
          px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a));
        }
        else
          px = (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a));

        r = std::sqrt((px - a)*(px - a) + (py - b)*(py - b));
        }

        flg = 1;
        for(long long int l = 0; l < N; l++){
          
          if(l == i || l ==j || l == k){
            continue;
          }
          if((x[l]-px)*(x[l]-px) + (y[l]-py)*(y[l]-py) > r*r+delta){
            flg = 0;
            break;
          }
        }
        if(flg == 1){
          ans = std::min(ans, r);
        }
      }
    }
  }

  for(long long int i = 0; i < N; i++){
    for(long long int j = i+1; j < N; j++){
      for(long long int k = j+1; k < N; k++){
        lij = ((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
        ljk = ((x[j]-x[k])*(x[j]-x[k]) + (y[j]-y[k])*(y[j]-y[k]));
        lki = ((x[k]-x[i])*(x[k]-x[i]) + (y[k]-y[i])*(y[k]-y[i]));

        flg = 0;
        if(lij > ljk+lki){
          px = 0.5 * (x[i]+x[j]);
          py = 0.5 * (y[i]+y[j]);
          r = std::sqrt(lij)*0.5;
          flg = 1;
        }
        else if(ljk > lij+lki){
          px = 0.5 * (x[k]+x[j]);
          py = 0.5 * (y[k]+y[j]);
          r = std::sqrt(ljk)*0.5;
          flg = 1;
        }
        else if(lki > lij + ljk){
          px = 0.5 * (x[k]+x[i]);
          py = 0.5 * (y[k]+y[i]);
          r = std::sqrt(lki)*0.5;
          flg = 1;
        }

        if(flg == 0)continue;

        flg = 1;
        for(long long int l = 0; l < N; l++){
          
          if(l == i || l ==j || l == k){
            continue;
          }
          if((x[l]-px)*(x[l]-px) + (y[l]-py)*(y[l]-py) > r*r+delta){
            flg = 0;
            break;
          }
        }
        if(flg == 1){
          ans = std::min(ans, r);
        }
      }
    }
  }
  

  std::cerr << "Answer: " << std::endl;
  std::cout << std::setprecision(10) << ans << std::endl;

  return 0;
}