Problem:


Score : 600 points

Problem Statement

There are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i).

Let R=10^{10^{10^{10}}}. Ringo performs the following operation:

Randomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen.

For every i (1 \leq i \leq N), find the probability that Snuke falls into the i-th hole.

Here, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows:

Pick two real numbers x and y independently according to uniform distribution on [-R,R].

If x^2+y^2\leq R^2, the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.

Constraints

2 \leq N \leq 100

|x_i|,|y_i| \leq 10^6(1\leq i\leq N)

All given points are pairwise distinct.

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
:
x_N y_N

Output

Print N real numbers. The i-th real number must represent the probability that Snuke falls into the i-th hole.

The output will be judged correct when, for all output values, the absolute or relative error is at most 10^{-5}.

Sample Input 1

2
0 0
1 1

Sample Output 1

0.5
0.5

If Ringo put Snuke in the region x+y\leq 1, Snuke will fall into the first hole. The probability of this happening is very close to 0.5.
Otherwise, Snuke will fall into the second hole, the probability of which happening is also very close to 0.5.

Sample Input 2

5
0 0
2 8
4 5
2 6
3 10

Sample Output 2

0.43160120892732328768
0.03480224363653196956
0.13880483535586193855
0.00000000000000000000
0.39479171208028279727



Sample input:
2
0 0
1 1


Sample output:
0.5
0.5

Submission status: Runtime Error

Solution code:
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    def det(p, q):
        return p[0] * q[1] - p[1] * q[0]

    def sub(p, q):
        return (p[0] - q[0], p[1] - q[1])

    def get_convex_hull(points):
        # どの3点も直線上に並んでいないと仮定する。
        n = len(points)
        points.sort()
        size_convex_hull = 0
        ch = []
        for i in range(n):
            while size_convex_hull > 1:
                v_cur = sub(ch[-1], ch[-2])
                v_new = sub(points[i], ch[-2])
                if det(v_cur, v_new) > 0:
                    break
                size_convex_hull -= 1
                ch.pop()
            ch.append(points[i])
            size_convex_hull += 1
        t = size_convex_hull
        for i in range(n - 2, -1, -1):
            while size_convex_hull > t:
                v_cur = sub(ch[-1], ch[-2])
                v_new = sub(points[i], ch[-2])
                if det(v_cur, v_new) > 0:
                    break
                size_convex_hull -= 1
                ch.pop()
            ch.append(points[i])
            size_convex_hull += 1
        return ch[:-1]
    def calc_deg(p,p1,p2):
        a1 = p1[0]-p[0]; a2 = p1[1]-p[1]
        b1 = p2[0]-p[0]; b2 = p2[1]-p[1]
        #print(p,p1,p2)
        #print(a1,a2,b1,b2)
        return (a1*b1+a2*b2)/(((a1**2+a2**2)**0.5)*((b1**2+b2**2)**0.5))
    N = I()
    P = [[]for _ in range(N)]
    D = defaultdict(int)
    for i in range(N):
        x,y = LI()
        P[i] = (x,y)
        D[(x,y)] = i
    C = get_convex_hull(P)
    #print(C)
    ans = [0]*N
    if len(C)==2:
        for c in C:
            ans[D[c]] = 0.5
        for v in ans:
            print(v)
        return
    for i,c in enumerate(C):
        cur = calc_deg(c,C[i-1],C[i-N+2])
        #print(cur,math.degrees(math.acos(cur)))
        ans[D[c]] = (math.pi-math.acos(cur))/(math.pi*2)
    for v in ans:
        print(v)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    S = SI()
    N = len(S)
    K = I()
    dp = [[[0 for _ in range(K+1)]for _ in range(N)]for _ in range(N)]
    for i in range(N):
        for j in range(K+1):
            dp[i][i][j] = 1
    for i in range(2,N+1):
        for k in range(K+1):
            for l,r in enumerate(range(i-1,N)):
                if S[l]==S[r]:
                    dp[l][r][k] = dp[l+1][r-1][k] + 2
                else:
                    if k>0:
                        dp[l][r][k] = max(dp[l+1][r][k],dp[l][r-1][k],dp[l+1][r-1][k-1]+2)
                    else:
                        dp[l][r][k] = max(dp[l + 1][r][k], dp[l][r - 1][k])
    ans = max(dp[0][-1])
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Runtime Error

Solution code:
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10**9 + 7
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



#11:00




n = int(input())
xy = []

for i in range(n):
    xy.append(list(map(int, input().split())))
    xy[-1].append(i)
    
origin = list(xy)
xy.sort(key = lambda x : -x[1])
xy.sort(key = lambda x : x[0])
#print(xy)

down = [0]

while(True):
    now = down[-1]
    nowxy = xy[down[-1]]
    #print(now,nowxy)
    if(now==n-1):
        break
    shouldBreak = 0
    for j in range(now+1,n):
        if(nowxy[0] == xy[j][0]):
            down.append(j)
            shouldBreak=1
            break
    if(shouldBreak):
        break
    gradmin = 10**18
    nxt = -1
    for j in range(now+1,n):
        grad = (xy[j][1]-nowxy[1])/(xy[j][0]-nowxy[0])
        #print(grad)
        if(gradmin > grad):
            gradmin = grad
            nxt = j
            
    down.append(nxt)
#print(down)
down = [xy[i][2] for i in down]
down = down[0:len(down)-1]
#print(down)

xy.sort(key = lambda x : x[1])
xy.sort(key = lambda x : -x[0])
#print(xy)

up = [0]
    
while(True):
    now = up[-1]
    nowxy = xy[up[-1]]
    #print(now,nowxy)
    if(now==n-1):
        break
    
    shouldBreak = 0
    for j in range(now+1,n):
        if(nowxy[0] == xy[j][0]):
            up.append(j)
            shouldBreak=1
            break
    if(shouldBreak):
        break
    gradmin = 10**18
    nxt = -1
    for j in range(now+1,n):
        grad = (xy[j][1]-nowxy[1])/(xy[j][0]-nowxy[0])
        if(gradmin > grad):
            #print("g",j,grad)
            gradmin = grad
            nxt = j
            
    up.append(nxt)
    #print(up)
#print(up)
up = [xy[i][2] for i in up]
up = up[:len(up)-1]
#print(up)
seq = list(down)
for i in up:
    seq.append(i)

#print(seq)

ans = [0.0 for i in range(n)]

def u2(a):
    return math.sqrt(a[0]*a[0]+a[1]*a[1])
def dot(a,b):
    return a[0]*b[0]+a[1]*b[1]

m = len(seq)
for i in range(len(seq)):
    num1,num2,num3 = seq[(i-1)%m],seq[i],seq[(i+1)%m]
    p1,p2,p3 = origin[num1],origin[num2], origin[num3]
    left = [p1[0]-p2[0],p1[1]-p2[1]]
    right = [p3[0]-p2[0],p3[1]-p2[1]]
    cos = dot(left,right)/u2(left)/u2(right)
    #print(cos,left,right)
    deg = math.pi - math.acos(cos)
    ans[num2] = deg/(2.0*math.pi)

for i in ans:
    print(i)

Submission status: Runtime Error

Solution code:
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10**9 + 7
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



#11:00




n = int(input())
xy = []

for i in range(n):
    xy.append(list(map(int, input().split())))
    xy[-1].append(i)
    
origin = list(xy)
xy.sort(key = lambda x : -x[1])
xy.sort(key = lambda x : x[0])
#print(xy)

down = [0]

while(True):
    now = down[-1]
    nowxy = xy[down[-1]]
    #print(now,nowxy)
    if(now==n-1):
        break
    
    for j in range(now+1,n):
        if(nowxy[0] == xy[j][0]):
            down.append(j)
            break
    gradmin = 10**18
    nxt = -1
    for j in range(now+1,n):
        grad = (xy[j][1]-nowxy[1])/(xy[j][0]-nowxy[0])
        #print(grad)
        if(gradmin > grad):
            gradmin = grad
            nxt = j
            
    down.append(nxt)
#print(down)
down = [xy[i][2] for i in down]
down = down[0:len(down)-1]
#print(down)

xy.sort(key = lambda x : x[1])
xy.sort(key = lambda x : -x[0])
#print(xy)

up = [0]
    
while(True):
    now = up[-1]
    nowxy = xy[up[-1]]
    #print(now,nowxy)
    if(now==n-1):
        break
    
    for j in range(now+1,n):
        if(nowxy[0] == xy[j][0]):
            up.append(j)
            break
    gradmin = 10**18
    nxt = -1
    for j in range(now+1,n):
        grad = (xy[j][1]-nowxy[1])/(xy[j][0]-nowxy[0])
        if(gradmin > grad):
            #print("g",j,grad)
            gradmin = grad
            nxt = j
            
    up.append(nxt)
    #print(up)
#print(up)
up = [xy[i][2] for i in up]
up = up[:len(up)-1]
#print(up)
seq = list(down)
for i in up:
    seq.append(i)

#print(seq)

ans = [0.0 for i in range(n)]

def u2(a):
    return math.sqrt(a[0]*a[0]+a[1]*a[1])
def dot(a,b):
    return a[0]*b[0]+a[1]*b[1]

m = len(seq)
for i in range(len(seq)):
    num1,num2,num3 = seq[(i-1)%m],seq[i],seq[(i+1)%m]
    p1,p2,p3 = origin[num1],origin[num2], origin[num3]
    left = [p1[0]-p2[0],p1[1]-p2[1]]
    right = [p3[0]-p2[0],p3[1]-p2[1]]
    cos = dot(left,right)/u2(left)/u2(right)
    #print(cos,left,right)
    deg = math.pi - math.acos(cos)
    ans[num2] = deg/(2.0*math.pi)

for i in ans:
    print(i)

Submission status: Runtime Error

Solution code:
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10**9 + 7
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



#11:00




n = int(input())
xy = []

for i in range(n):
    xy.append(list(map(int, input().split())))
    xy[-1].append(i)
    
origin = list(xy)
xy.sort(key = lambda x : -x[1])
xy.sort(key = lambda x : x[0])
#print(xy)

down = [0]

while(True):
    now = down[-1]
    nowxy = xy[down[-1]]
    #print(now,nowxy)
    if(now==n-1):
        break
    
    for j in range(now+1,n):
        if(nowxy[0] == xy[j][0]):
            down.append(j)
            break
    gradmin = 10**18
    nxt = -1
    for j in range(now+1,n):
        grad = (xy[j][1]-nowxy[1])/(xy[j][0]-nowxy[0])
        #print(grad)
        if(gradmin > grad):
            gradmin = grad
            nxt = j
            
    down.append(j)
#print(down)
down = [xy[i][2] for i in down]
down = down[0:len(down)-1]
#print(down)

xy.sort(key = lambda x : x[1])
xy.sort(key = lambda x : -x[0])
#print(xy)

up = [0]
    
while(True):
    now = up[-1]
    nowxy = xy[up[-1]]
    #print(now,nowxy)
    if(now==n-1):
        break
    
    for j in range(now+1,n):
        if(nowxy[0] == xy[j][0]):
            up.append(j)
            break
    gradmin = 10**18
    nxt = -1
    for j in range(now+1,n):
        grad = (xy[j][1]-nowxy[1])/(xy[j][0]-nowxy[0])
        if(gradmin > grad):
            #print("g",j,grad)
            gradmin = grad
            nxt = j
            
    up.append(nxt)
    #print(up)
#print(up)
up = [xy[i][2] for i in up]
up = up[:len(up)-1]
#print(up)
seq = list(down)
for i in up:
    seq.append(i)

#print(seq)

ans = [0.0 for i in range(n)]

def u2(a):
    return math.sqrt(a[0]*a[0]+a[1]*a[1])
def dot(a,b):
    return a[0]*b[0]+a[1]*b[1]

m = len(seq)
for i in range(len(seq)):
    num1,num2,num3 = seq[(i-1)%m],seq[i],seq[(i+1)%m]
    p1,p2,p3 = origin[num1],origin[num2], origin[num3]
    left = [p1[0]-p2[0],p1[1]-p2[1]]
    right = [p3[0]-p2[0],p3[1]-p2[1]]
    cos = dot(left,right)/u2(left)/u2(right)
    #print(cos,left,right)
    deg = math.pi - math.acos(cos)
    ans[num2] = deg/(2.0*math.pi)

for i in ans:
    print(i)

Submission status: Runtime Error

Solution code:
import math

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

if N == 2:
    print(0.5)
    print(0.5)
    exit()

outside = []
for i in range(N):
    x1, y1 = xys[i]
    for j in range(i+1, N):
        x2, y2 = xys[j]
        sign = 0
        for x3, y3 in xys:
            tmp = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)
            if tmp == 0:
                continue
            elif tmp > 0:
                if sign == 0:
                    sign = +1
                elif sign == -1:
                    continue_flg = True
                    break
                else:
                    continue
            else:
                if sign == 0:
                    sign = -1
                elif sign == +1:
                    continue_flg = True
                    break
                else:
                    continue
        else:
            outside.append(i)
            outside.append(j)
            continue_flg = False
            break
    if continue_flg == False:
        break

go_back_to_while = False
while True:
    i = outside[-1]
    x1, y1 = xys[i]
    for j in range(N):
        if j in outside:
            continue
        x2, y2 = xys[j]
        sign = 0
        for k, (x3, y3) in enumerate(xys):
            if k == i or k == j:
                continue
            tmp = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)
            if tmp == 0:
                if x1 < x3 < x2 or x1 > x3 > x2 or y1 < y3 < y2 or y1 > y3 > y2:
                    if k in outside:
                        outside.remove(k)
                        outside.append(j)
                        go_back_to_while = True
                        break
                elif x1 < x2 < x3 or x1 > x2 > x3 or y1 < y2 < y3 or y1 > y2 > y3:
                    break
                else:
                    outside.pop() #remove i
                    go_back_to_while = True
                    break
            elif tmp > 0:
                if sign == 0:
                    sign = +1
                elif sign == -1:
                    break
                else:
                    continue
            else:
                if sign == 0:
                    sign = -1
                elif sign == +1:
                    break
                else:
                    continue
        else:
            outside.append(j)
            break
        if go_back_to_while:
            go_back_to_while = False
            break
    else: #when not found appropriate j
        break #get out of while True


ans = [0.0] * N

for i in range(-1, len(outside) - 1):
    x1, y1 = xys[outside[i-1]]
    x2, y2 = xys[outside[i]]
    x3, y3 = xys[outside[i+1]]
    v1x, v1y = x2 - x1, y2 - y1
    v2x, v2y = x3 - x2, y3 - y2
    dot = v1x * v2x + v1y * v2y
    len1 = (v1x ** 2 + v1y ** 2)
    len2 = (v2x ** 2 + v2y ** 2)
    ans[outside[i]] = math.acos( max(-1.0, min(1.0, dot / math.sqrt(len1 * len2))) ) / (2 * math.pi)

for a in ans:
    print('{:.20f}'.format(a))

Submission status: Runtime Error

Solution code:
import math

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

if N == 2:
    print(0.5)
    print(0.5)
    exit()

outside = []
for i in range(N):
    x1, y1 = xys[i]
    for j in range(i+1, N):
        x2, y2 = xys[j]
        sign = 0
        for x3, y3 in xys:
            tmp = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)
            if tmp == 0:
                continue
            elif tmp > 0:
                if sign == 0:
                    sign = +1
                elif sign == -1:
                    continue_flg = True
                    break
                else:
                    continue
            else:
                if sign == 0:
                    sign = -1
                elif sign == +1:
                    continue_flg = True
                    break
                else:
                    continue
        else:
            outside.append(i)
            outside.append(j)
            continue_flg = False
            break
    if continue_flg == False:
        break

while True:
    i = outside[-1]
    x1, y1 = xys[i]
    for j in range(N):
        if j in outside:
            continue
        x2, y2 = xys[j]
        sign = 0
        for x3, y3 in xys:
            tmp = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)
            if tmp == 0:
                continue
            elif tmp > 0:
                if sign == 0:
                    sign = +1
                elif sign == -1:
                    continue_flg = True
                    break
                else:
                    continue
            else:
                if sign == 0:
                    sign = -1
                elif sign == +1:
                    continue_flg = True
                    break
                else:
                    continue
        else:
            outside.append(j)
            continue_flg = False
            break
    else: #when not found appropriate j
        break #get out of while True

ans = [0.0] * N

for i in range(-1, len(outside) - 1):
    x1, y1 = xys[outside[i-1]]
    x2, y2 = xys[outside[i]]
    x3, y3 = xys[outside[i+1]]
    v1x, v1y = x2 - x1, y2 - y1
    v2x, v2y = x3 - x2, y3 - y2
    dot = v1x * v2x + v1y * v2y
    len1 = (v1x ** 2 + v1y ** 2) ** 0.5
    len2 = (v2x ** 2 + v2y ** 2) ** 0.5
    ans[outside[i]] = math.acos( dot / (len1 * len2) ) / (2 * math.pi)

for a in ans:
    print('{:.7f}'.format(a))

Submission status: Runtime Error

Solution code:
import math

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

if N == 2:
    print(0.5)
    print(0.5)
    exit()

outside = []
for i in range(N):
    x1, y1 = xys[i]
    for j in range(i+1, N):
        x2, y2 = xys[j]
        sign = 0
        for x3, y3 in xys:
            tmp = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)
            if tmp == 0:
                continue
            elif tmp > 0:
                if sign == 0:
                    sign = +1
                elif sign == -1:
                    continue_flg = True
                    break
                else:
                    continue
            else:
                if sign == 0:
                    sign = -1
                elif sign == +1:
                    continue_flg = True
                    break
                else:
                    continue
        else:
            outside.append(i)
            outside.append(j)
            continue_flg = False
            break
    if continue_flg == False:
        break

while True:
    i = outside[-1]
    x1, y1 = xys[i]
    for j in range(N):
        if i == j:
            continue
        if outside[-2] == j:
            continue
        if outside[0] == j:
            continue
        x2, y2 = xys[j]
        sign = 0
        for x3, y3 in xys:
            tmp = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)
            if tmp == 0:
                continue
            elif tmp > 0:
                if sign == 0:
                    sign = +1
                elif sign == -1:
                    continue_flg = True
                    break
                else:
                    continue
            else:
                if sign == 0:
                    sign = -1
                elif sign == +1:
                    continue_flg = True
                    break
                else:
                    continue
        else:
            outside.append(j)
            continue_flg = False
            break
    else: #when not found appropriate j
        break #get out of while True

ans = [0.0] * N

for i in range(-1, len(outside) - 1):
    x1, y1 = xys[outside[i-1]]
    x2, y2 = xys[outside[i]]
    x3, y3 = xys[outside[i+1]]
    v1x, v1y = x2 - x1, y2 - y1
    v2x, v2y = x3 - x2, y3 - y2
    dot = v1x * v2x + v1y * v2y
    len1 = (v1x ** 2 + v1y ** 2) ** 0.5
    len2 = (v2x ** 2 + v2y ** 2) ** 0.5
    ans[outside[i]] = math.acos( dot / (len1 * len2) ) / math.tau # = 2pi

print(*ans, sep = '\n')

Submission status: Runtime Error

Solution code:
import math

def norm(p, q): # normal vector: (p -> q) * -1j
    return (q[1] - p[1], p[0] - q[1])

def magnitude(a):
    return (a[0]**2 + a[1]**2)**.5

def dot(p, q):
    return p[0]*q[0] + p[1]*q[1]

def angle(p, q):
    return math.acos(dot(p, q) / (magnitude(p) * magnitude(q)))

def cross(a, b, c):
    return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0])

def convex_hull(ps):
    ps = sorted(ps)
    qs = []
    n = len(ps)
    for p in ps:
        while len(qs) > 1 and cross(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    t = len(qs)
    for i in range(n - 2, -1, -1):
        p = ps[i]
        while len(qs) > t and cross(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    return qs

n = int(input())
s = [tuple(map(int, input().split())) for _ in range(n)]
ch = convex_hull(s)
ch.pop()
m = len(ch)
d = dict()
for i in range(m):
  u = angle(norm(ch[i-1], ch[i]), norm(ch[i], ch[(i+1)%m]))
  d[ch[i]] = u / 2 / math.pi
for t in s:
  print(0.0 if t not in d else d[t])