Problem p02805 (python)

Fixed submission:
import sys
from math import hypot
readline = sys.stdin.readline

N = int(readline())
Points = [tuple(map(int, readline().split())) for _ in range(N)]

inf = 10**9+7
EPS = 1e-8
ans = inf
for i in range(N):
    for j in range(i):
        a = Points[i][0]
        b = Points[i][1]
        c = Points[j][0]
        d = Points[j][1]
        px, py = (a+c)/2, (b+d)/2
        R = hypot(a-px, b-py)
        if all(hypot(px-xi, py-yi) <= R+EPS for xi, yi in Points):
            ans = min(ans, R)
            
for i in range(N):
    for j in range(i):
        for k in range(j):
            a = Points[i][0]
            b = Points[i][1]
            c = Points[j][0]
            d = Points[j][1]
            e = Points[k][0]
            f = Points[k][1]
            
            ea = hypot(c-e, d-f) + EPS
            eb = hypot(a-e, b-f) + EPS
            ec = hypot(a-c, b-d) + EPS
            cA = (ec**2+eb**2-ea**2)/(2*ec*eb)
            cB = (ec**2-eb**2+ea**2)/(2*ec*ea)
            cC = (-ec**2+eb**2+ea**2)/(2*ea*eb)
            sA = (1-cA**2)**0.5
            sB = (1-cB**2)**0.5
            sC = (1-cC**2)**0.5
            s2A = 2*sA*cA
            s2B = 2*sB*cB
            s2C = 2*sC*cC
            if max(s2A, s2B, s2C) < EPS:
                continue
            else:
                px = (a*s2A + c*s2B + e*s2C)/(s2A+s2B+s2C)
                py = (b*s2A + d*s2B + f*s2C)/(s2A+s2B+s2C)
                R = hypot(px - a, py - b)
            
            if all(hypot(px-xi, py-yi) <= R+EPS for xi, yi in Points):
                ans = min(ans, R)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from math import hypot
readline = sys.stdin.readline

N = int(readline())
Points = [tuple(map(int, readline().split())) for _ in range(N)]

inf = 10**9+7
EPS = 1e-8
ans = inf
for i in range(N):
    for j in range(i):
        a = Points[i][0]
        b = Points[i][1]
        c = Points[j][0]
        d = Points[j][1]
        px, py = (a+c)/2, (b+d)/2
        R = hypot(a-px, b-py)
        if all(hypot(px-xi, py-yi) <= R+EPS for xi, yi in Points):
            ans = min(ans, R)
            
for i in range(N):
    for j in range(i):
        for k in range(j):
            a = Points[i][0]
            b = Points[i][1]
            c = Points[j][0]
            d = Points[j][1]
            e = Points[k][0]
            f = Points[k][1]
            
            ea = hypot(c-e, d-f)
            eb = hypot(a-e, b-f)
            ec = hypot(a-c, b-d)
            cA = (ec**2+eb**2-ea**2)/(2*ec*eb)
            cB = (ec**2-eb**2+ea**2)/(2*ec*ea)
            cC = (-ec**2+eb**2+ea**2)/(2*ea*eb)
            sA = (1-cA**2)**0.5
            sB = (1-cB**2)**0.5
            sC = (1-cC**2)**0.5
            s2A = 2*sA*cA
            s2B = 2*sB*cB
            s2C = 2*sC*cC
            if max(s2A, s2B, s2C) < EPS:
                continue
            else:
                px = (a*s2A + c*s2B + e*s2C)/(s2A+s2B+s2C)
                py = (b*s2A + d*s2B + f*s2C)/(s2A+s2B+s2C)
                R = hypot(px - a, py - b)
            
            if all(hypot(px-xi, py-yi) <= R+EPS for xi, yi in Points):
                ans = min(ans, R)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from math import hypot, sin
readline = sys.stdin.readline

N = int(readline())
Points = [tuple(map(int, readline().split())) for _ in range(N)]

if N == 2:
    x1, y1 = Points[0]
    x2, y2 = Points[1]
    ans = hypot(x1-x2, y1-y2)/2
else:
    
    inf = 10**9+7
    EPS = 1e-8
    ans = inf
    for i in range(N):
        for j in range(i):
            for k in range(j):
                a = Points[i][0]
                b = Points[i][1]
                c = Points[j][0]
                d = Points[j][1]
                e = Points[k][0]
                f = Points[k][1]
                
                ea = hypot(c-e, d-f)
                eb = hypot(a-e, b-f)
                ec = hypot(a-c, b-d)
                cA = (ec**2+eb**2-ea**2)/(2*ec*eb)
                cB = (ec**2-eb**2+ea**2)/(2*ec*ea)
                cC = (-ec**2+eb**2+ea**2)/(2*ea*eb)
                sA = (1-cA**2)**0.5
                sB = (1-cB**2)**0.5
                sC = (1-cC**2)**0.5
                if max(sA, sB, sC) < EPS:
                    if ec-EPS <= ea + eb <= ec+EPS:
                        px, py = (a+c)/2, (b+d)/2
                        R = ec/2
                    elif eb-EPS <= ea + ec <= eb+EPS:
                        px, py = (a+e)/2, (b+f)/2
                        R = eb/2
                    else:
                        px, py = (c+e)/2, (d+f)/2
                        R = ea/2
                else:  
                    s2A = 2*sA*cA
                    s2B = 2*sB*cB
                    s2C = 2*sC*cC
                    px = (a*s2A + c*s2B + e*s2C)/(s2A+s2B+s2C)
                    py = (b*s2A + d*s2B + f*s2C)/(s2A+s2B+s2C)
                    R = hypot(px - a, py - b)
                
                if all(hypot(px-xi, py-yi) <= R+EPS for xi, yi in Points):
                    ans = min(ans, R)
print(ans)