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# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using CompLib.Mathematics;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        double[] x = new double[n];
        double[] y = new double[n];
        for (int i = 0; i < n; i++)
        {
            x[i] = sc.NextDouble();
            y[i] = sc.NextDouble();
        }

        double xx, yy, rr;
        Point.InclusionCircle(x, y, out xx, out yy, out rr);
        Console.WriteLine(rr);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

namespace CompLib.Mathematics
{
    public static partial class Equation
    {
        /// <summary>
        /// ax + b = 0
        /// xを求める
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static double LinearEquation(double a, double b)
        {
            return -b / a;
        }

        /// <summary>
        /// ax + by + c = 0
        /// dx + ey + f = 0
        /// x,yを求める
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="c"></param>
        /// <param name="d"></param>
        /// <param name="e"></param>
        /// <param name="f"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public static void SimultaneousEquations(double a, double b, double c, double d, double e, double f,
            out double x, out double y)
        {
            /*
             * ax + by + c = 0
             * dx + ey + f = 0
             *
             * adx + bdy + cd = 0
             * adx + aey + af = 0
             *
             * (bd - ae)y + (cd - af) = 0 
             */

            if (a == 0)
            {
                LinearEquation(b, c);
            }

            y = LinearEquation(b * d - a * e, d * c - a * f);
            x = a == 0 ? LinearEquation(d, e * y + f) : LinearEquation(a, b * y + c);
        }
    }
}

namespace CompLib.Mathematics
{
    using System;

    public static partial class Point
    {
        /// <summary>
        /// 原点から (x,y)までの距離
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public static double Dist(double x, double y)
        {
            return Math.Sqrt(x * x + y * y);
        }

        /// <summary>
        /// 点1 (x1,y1) から 点2 (x2,y2)までの距離
        /// </summary>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <returns></returns>
        public static double Dist(double x1, double y1, double x2, double y2)
        {
            return Dist(x2 - x1, y2 - y1);
        }

        /// <summary>
        /// 原点 (x1,y1) (x2,y2)を頂点とする三角形の面積
        /// </summary>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <returns></returns>
        public static double TriangleArea(double x1, double y1, double x2, double y2)
        {
            return Math.Abs(x1 * y2 - x2 * y1) / 2;
        }

        /// <summary>
        /// (x1,y1) (x2,y2) (x3,y3)を頂点とする三角形の面積
        /// </summary>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="x3"></param>
        /// <param name="y3"></param>
        /// <returns></returns>
        public static double TriangleArea(double x1, double y1, double x2, double y2, double x3, double y3)
        {
            return TriangleArea(x1 - x3, y1 - y3, x2 - x3, y2 - y3);
        }

        /// <summary>
        /// 原点O 点A (x1,y1) B (x2,y2)
        /// ∠AOB 
        /// </summary>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <returns></returns>
        public static double Angle(double x1, double y1, double x2, double y2)
        {
            double r = Math.Abs(Math.Atan2(y1, x1) - Math.Atan2(y2, x2));
            return r > Math.PI ? 2 * Math.PI - r : r;
        }

        /// <summary>
        /// 点 A (x1,y1) B(x2,y2) C(x3,y3)
        /// ∠ABC
        /// </summary>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="x3"></param>
        /// <param name="y3"></param>
        /// <returns></returns>
        public static double Angle(double x1, double y1, double x2, double y2, double x3, double y3)
        {
            return Angle(x1 - x2, y1 - y2, x3 - x2, y3 - y2);
        }


        /// <summary>
        /// 点 1,2,3を頂点とする三角形の外接円
        /// </summary>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="x3"></param>
        /// <param name="y3"></param>
        public static bool Circle(double x1, double y1, double x2, double y2, double x3, double y3, out double x,
            out double y, out double r)
        {
            x = -1;
            y = -1;
            r = -1;
            // 三角形が作れない
            if (x1 == x2 && x2 == x3)
            {
                return false;
            }

            if (y1 == y2 && y2 == y3)
            {
                return false;
            }

            // 2r = a/sinA
            double thetaA = Angle(x3, y3, x1, y1, x2, y2);
            
            double a = Dist(x2, y2, x3, y3);
            r = a / Math.Sin(thetaA) / 2;

            // r^2 = (x1-x)^2 + (y1-y)^2
            //     = x1^2 - 2・x1・x + x^2 + y1^2 - 2・y1・y + y^2
            /*
             * x1^2 - 2*x1*x + y1^2 - 2・y1・y = x2^2 - 2*x2*x + y2^2 - 2*y2*y
             * x1^2 - 2・x1・x + y2^2 - 2・y1・y = x3^2 - 2・x3・x + y3^2 - 2・y3・y
             *
             * 上の2元1次方程式解く
             *
             * x1^2 + y1^2 - x2^2 - y2^2 = 2*x1*x + 2*y1*y - 2*x2*x - 2*y2*y
             * x1^2 + y1^2 - x3^2 - y3^2 = 2*x1*x + 2*y1*y - 2*x3*x - 2*y3*y
             *
             * x1^2 + y1^2 - x2^2 - y2^2 = A
             * x1^2 + y1^2 - x3^2 - y3^2 = B
             * 2*x1 = C
             * 2*y1 = D
             * 2*x2 = E
             * 2*y2 = F
             * 2*x3 = G
             * 2*y3 = H
             * 
             *  (C-E)x + (D-F)y - A = 0
             *  (C-G)x + (D-H)y - B = 0
             *
             * 
             */

            double A = 2 * x1 - 2 * x2;
            double B = 2 * y1 - 2 * y2;
            double C = x2 * x2 + y2 * y2 - x1 * x1 - y1 * y1;
            
            double D = 2 * x1 - 2 * x3;
            double E = 2 * y1 - 2 * y3;
            double F = x3 * x3 + y3 * y3 - x1 * x1 - y1 * y1;
            
            Equation.SimultaneousEquations(A, B, C, D, E, F, out x, out y);

            return true;
        }

        /// <summary>
        /// (xi,yi)をすべて含む最小の円 len(x) = len(y) >= 2
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="cx"></param>
        /// <param name="cy"></param>
        /// <param name="cr"></param>
        public static void InclusionCircle(double[] x, double[] y, out double cx, out double cy, out double cr)
        {
            cx = -1;
            cy = -1;
            cr = double.MaxValue;
            // 2点が円の直径
            for (int i = 0; i < x.Length - 1; i++)
            {
                for (int j = i + 1; j < x.Length; j++)
                {
                    double tmpCx = (x[i] + x[j]) / 2;
                    double tmpCy = (y[i] + y[j]) / 2;
                    double tmpCr = Dist(tmpCx, tmpCy, x[i], y[i]);
                    if (Inclusion(x, y, tmpCx, tmpCy, tmpCr))
                    {
                        if (tmpCr < cr)
                        {
                            cx = tmpCx;
                            cy = tmpCy;
                            cr = tmpCr;
                        }
                    }
                }
            }

            for (int i = 0; i < x.Length - 2; i++)
            {
                for (int j = i + 1; j < x.Length - 1; j++)
                {
                    for (int k = j + 1; k < x.Length; k++)
                    {
                        double tmpCx;
                        double tmpCy;
                        double tmpCr;
                        if (Circle(x[i], y[i], x[j], y[j], x[k], y[k], out tmpCx, out tmpCy, out tmpCr))
                        {
                            if (Inclusion(x, y, tmpCx, tmpCy, tmpCr))
                            {
                                if (tmpCr < cr)
                                {
                                    cx = tmpCx;
                                    cy = tmpCy;
                                    cr = tmpCr;
                                }
                            }
                        }
                    }
                }
            }
        }


        /// <summary>
        /// 中心 (cx,cy) 半径 cr (xi,yi)をすべて含むか
        /// 
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="cx"></param>
        /// <param name="cy"></param>
        /// <param name="cr"></param>
        /// <returns></returns>
        public static bool Inclusion(double[] x, double[] y, double cx, double cy, double cr)
        {
            for (int i = 0; i < x.Length; i++)
            {
                double dx = x[i] - cx;
                double dy = y[i] - cy;
                if (cr * cr < dx * dx + dy * dy)
                {
                    return false;
                }
            }

            return true;
        }
    }
}