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: Wrong Answer

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( max(-1.0, min(1.0, dot / (len1 * len2))) ) / (2 * math.pi)

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

Submission status: Wrong Answer

Solution code:
import math

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)
cx = sum(x[0] for x in ch) / m
cy = sum(x[1] for x in ch) / m
ch2 = [(x - cx, y - cy) for x, y in ch]
cr = [math.atan2(y, x) for x, y in ch2]
d = dict()
for i in range(m):
  u = cr[i-1]
  v = cr[(i+1)%m]
  if u > cr[i]:
    u -= 2*math.pi
  if cr[i] > v:
    v += 2*math.pi
  d[ch[i]] = (v - u) / 4 / math.pi
for t in s:
  print(0.0 if t not in d else d[t])

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
cnt = [0 for i in range(n)]
p = [tuple(map(int, input().split( ))) for i in range(n)]
for i in range(10**6):
    x,y = math.cos(2*math.pi*i/10**6),math.sin(2*math.pi*i/10**6)
    tmp =[x*p[j][0]+y*p[j][0] for j in range(n)]
    mn_id = tmp.index(min(tmp))
    cnt[mn_id] += 1
    
for i in range(n):
    print(cnt[i]/10**6)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
M = 0
X = [0]
def inner_prod(x, y):
  S = 0
  for i in range(len(x)):
    S += x[i] * y[i]
  return S

for i in range(N):
  sqd = inner_prod(A[i], A[i])
  if sqd > M:
    M = sqd
    X[0] = i
p = 0
cnt = 0
vec1 = [1, 0]
while p == 0:
  j = X[cnt]
  l = 0
  Mj = -3
  dist = 0
  for k in range(N):
    if k != j:
      vec2 = [A[k][x] - A[j][x] for x in range(2)]
      c = inner_prod(vec2, vec1)
      sqd2 = inner_prod(vec1, vec1) * inner_prod(vec2, vec2)
      if Mj < c / (sqd2 ** (1/2)):
        Mj = c / (sqd2 ** (1/2))
        l = k
        dist = sqd2
      elif Mj == c / (sqd2 ** (1/2)):
        if dist > sqd2:
          Mj = c / (sqd2 ** (1/2))
          l = k
          dist = sqd2
  vec1[:] = [A[l][x] - A[j][x] for x in range(2)]
  X.append(l)
  cnt += 1
  if l == X[0]:
    p = 1

sudmat = []
for lg in range(len(X)-1):
  vec4 = [A[X[lg+1]][_] - A[X[lg]][_] for _ in range(2)]
  sudmat.append([-vec4[1], vec4[0]])
prob = [0 for i in range(N)]
for ring in range(len(X)-1):
  sister = inner_prod(sudmat[ring], sudmat[(ring+1)%(len(X)-1)])
  maids = inner_prod(sudmat[ring], sudmat[ring])
  maids *= inner_prod(sudmat[(ring+1)%(len(X)-1)], sudmat[(ring+1)%(len(X)-1)])
  maids **= 0.5
  theta = sister / maids
  if theta > 1:
    theta = 1
  elif theta < -1:
    theta = -1
  prob[X[ring+1]] = math.acos(theta) / (2 * math.pi)
for i in range(N):
  print(prob[i])

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
M = 0
X = [0]
def inner_prod(x, y):
  S = 0
  for i in range(len(x)):
    S += x[i] * y[i]
  return S

for i in range(N):
  sqd = inner_prod(A[i], A[i])
  if sqd > M:
    M = sqd
    X[0] = i
p = 0
cnt = 0
vec1 = [1, 0]
while p == 0:
  j = X[cnt]
  l = 0
  Mj = -3
  dist = 0
  for k in range(N):
    if k != j:
      vec2 = [A[k][x] - A[j][x] for x in range(2)]
      c = inner_prod(vec2, vec1)
      sqd2 = inner_prod(vec1, vec1) * inner_prod(vec2, vec2)
      if Mj < c / (sqd2 ** (1/2)):
        Mj = c / (sqd2 ** (1/2))
        l = k
        dist = sqd2
      elif Mj == c / (sqd2 ** (1/2)):
        if dist > sqd2:
          Mj = c / (sqd2 ** (1/2))
          l = k
          dist = sqd2
  vec1[:] = [A[l][x] - A[j][x] for x in range(2)]
  X.append(l)
  cnt += 1
  if l == X[0]:
    p = 1

sudmat = []
for lg in range(len(X)-1):
  vec4 = [A[X[lg+1]][_] - A[X[lg]][_] for _ in range(2)]
  sudmat.append([-vec4[1], vec4[0]])
prob = [0 for i in range(N)]
for ring in range(len(X)-1):
  sister = inner_prod(sudmat[ring], sudmat[(ring+1)%(len(X)-1)])
  maids = (inner_prod(sudmat[ring], sudmat[ring])) ** (1/2)
  maids *= (inner_prod(sudmat[(ring+1)%(len(X)-1)], sudmat[(ring+1)%(len(X)-1)])) ** (1/2)
  theta = sister / maids
  if theta > 1:
    theta = 1
  elif theta < -1:
    theta = -1
  prob[X[ring+1]] = math.acos(theta) / (2 * math.pi)
for i in range(N):
  print(prob[i])

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
M = 0
X = [0]
def inner_prod(x, y):
  S = 0
  for i in range(len(x)):
    S += x[i] * y[i]
  return S

for i in range(N):
  sqd = inner_prod(A[i], A[i])
  if sqd > M:
    M = sqd
    X[0] = i
p = 0
cnt = 0
vec1 = [1, 0]
while p == 0:
  j = X[cnt]
  l = 0
  Mj = -3
  for k in range(N):
    if k != j:
      vec2 = [A[k][x] - A[j][x] for x in range(2)]
      c = inner_prod(vec2, vec1)
      sqd2 = inner_prod(vec1, vec1) * inner_prod(vec2, vec2)
      if Mj < c / (sqd2 ** (1/2)):
        Mj = c / (sqd2 ** (1/2))
        l = k
  vec1[:] = [A[l][x] - A[j][x] for x in range(2)]
  X.append(l)
  cnt += 1
  if l == X[0]:
    p = 1
sudmat = []
for lg in range(len(X)-1):
  vec4 = [A[X[lg+1]][_] - A[X[lg]][_] for _ in range(2)]
  sudmat.append([-vec4[1], vec4[0]])
prob = [0 for i in range(N)]
for ring in range(len(X)-1):
  sister = inner_prod(sudmat[ring], sudmat[(ring+1)%(len(X)-1)])
  maids = (inner_prod(sudmat[ring], sudmat[ring])) ** (1/2)
  maids *= (inner_prod(sudmat[(ring+1)%(len(X)-1)], sudmat[(ring+1)%(len(X)-1)])) ** (1/2)
  prob[X[ring+1]] = math.acos(sister / maids) / (2 * math.pi)
for i in range(N):
  print(prob[i])

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
from math import atan2, pi
readline = sys.stdin.readline
def cross(o, a, b):
    return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])

Prob = Counter()
N = int(readline())
Points = [tuple(map(int, readline().split())) for _ in range(N)]
Pointsorig = Points[:]
Points.sort()

lower = []
for p in Points:
    while len(lower) >= 2 and cross(lower[-2], lower[-1], p) < 0:
        lower.pop()
    lower.append(p)
upper = []
for p in Points[::-1]:
    while len(upper) >= 2 and cross(upper[-2], upper[-1], p) < 0:
        upper.pop()
    upper.append(p)

convexhull = lower[1:-1] + upper
M = len(convexhull)
convexhull += [convexhull[0]]
convexhull += [convexhull[1]]

for i in range(1, M+1):
    pn = convexhull[i]
    A = (convexhull[i-1][1] - pn[1] , convexhull[i-1][0] - pn[0])
    B = (convexhull[i+1][1] - pn[1] , convexhull[i+1][0] - pn[0])
    theta = pi - abs(atan2(*A) - atan2(*B))
    if theta < 0:
        theta += 2*pi
    Prob[pn] = theta/(2*pi)
Ans = [0]*N
for i in range(N):
    Ans[i] = Prob[Pointsorig[i]]
print('\n'.join(map(str, Ans)))

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
from math import atan2, pi
readline = sys.stdin.readline
def cross(o, a, b):
    return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])

Prob = Counter()
N = int(readline())
Points = [tuple(map(int, readline().split())) for _ in range(N)]
Pointsorig = Points[:]
Points.sort()

lower = []
for p in Points:
    while len(lower) >= 2 and cross(lower[-2], lower[-1], p) < 0:
        lower.pop()
    lower.append(p)
upper = []
for p in Points[::-1]:
    while len(upper) >= 2 and cross(upper[-2], upper[-1], p) < 0:
        upper.pop()
    upper.append(p)

convexhull = lower[1:-1] + upper
M = len(convexhull)
convexhull += [convexhull[0]]
convexhull += [convexhull[1]]

for i in range(1, M+1):
    pn = convexhull[i]
    A = (convexhull[i-1][1] - pn[1] , convexhull[i-1][0] - pn[0])
    B = (convexhull[i+1][1] - pn[1] , convexhull[i+1][0] - pn[0])
    theta = pi - atan2(*A) + atan2(*B)
    if theta < 0:
        theta += 2*pi
    Prob[pn] = theta/(2*pi)
Ans = [0]*N
for i in range(N):
    Ans[i] = Prob[Pointsorig[i]]
print('\n'.join(map(str, Ans)))

Submission status: Wrong Answer

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

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

Theta = [[0, 0] for _ in range(N)]

for i in range(N-1):
    x1, y1 = XY[i]
    for j in range(i+1, N):
        x2, y2 = XY[j]
        if x1 == x2:
            all_right = True
            all_left = True
            for k in range(N):
                if k == i or k == j: continue
                x3, y3 = XY[k]
                if x3 > x1:
                    all_left = False
                elif x3 < x1:
                    all_right = False
            if all_right:
                if y1 > y2:
                    Theta[i][1] = math.pi
                    Theta[j][0] = math.pi
                elif y1 < y2:
                    Theta[i][0] = math.pi
                    Theta[j][1] = math.pi
        else:
            all_up = True
            all_down = True
            for k in range(N):
                if k == i or k == j: continue
                x3, y3 = XY[k]
                if (y3-y1)*(x1-x2) < (y1-y2)*(x3-x1):
                    if x1-x2 > 0:
                        all_up = False
                    elif x1-x2 < 0:
                        all_down = False
                elif (y3-y1)*(x1-x2) > (y1-y2)*(x3-x1):
                    if x1-x2 > 0:
                        all_down = False
                    elif x1-x2 < 0:
                        all_up = False
            if all_down:
                if x1 < x2:
                    theta = math.atan2(x2-x1, y1-y2)
                    Theta[i][0] = theta
                    Theta[j][1] = theta
                else:
                    theta = math.atan2(x1-x2, y2-y1)
                    Theta[i][1] = theta
                    Theta[j][0] = theta
            if all_up:
                if x1 < x2:
                    theta = math.atan2(x1-x2, y2-y1)
                    Theta[i][1] = theta
                    Theta[j][0] = theta
                else:
                    theta = math.atan2(x2-x1, y1-y2)
                    Theta[i][0] = theta
                    Theta[j][1] = theta

for start, end in Theta:
    delta = end - start
    while delta < 0:
        delta += 2*math.pi
    while delta >= 2*math.pi:
        delta -= 2*math.pi
    print(delta/(2*math.pi))

Submission status: Wrong Answer

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

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

Theta = [[0, 0] for _ in range(N)]

for i in range(N-1):
    x1, y1 = XY[i]
    for j in range(i+1, N):
        x2, y2 = XY[j]
        if x1 == x2:
            all_right = True
            all_left = True
            for k in range(N):
                if k == i or k == j: continue
                x3, y3 = XY[k]
                if x3 > x1:
                    all_left = False
                elif x3 < x1:
                    all_right = False
            if all_right:
                if y1 > y2:
                    Theta[i][1] = math.pi
                    Theta[j][0] = math.pi
                elif y1 < y2:
                    Theta[i][0] = math.pi
                    Theta[j][1] = math.pi
        else:
            all_up = True
            all_down = True
            for k in range(N):
                if k == i or k == j: continue
                x3, y3 = XY[k]
                if (y3-y1)*(x1-x2) < (y1-y2)*(x3-x1):
                    if x1-x2 > 0:
                        all_up = False
                    elif x1-x2 < 0:
                        all_down = False
                elif (y3-y1)*(x1-x2) > (y1-y2)*(x3-x1):
                    if x1-x2 > 0:
                        all_down = False
                    elif x1-x2 < 0:
                        all_up = False
            if all_down:
                if x1 < x2:
                    theta = math.atan2(x2-x1, y1-y2)
                    Theta[i][0] = theta
                    Theta[j][1] = theta
                else:
                    theta = math.atan2(x1-x2, y2-y1)
                    Theta[i][1] = theta
                    Theta[j][0] = theta
            if all_up:
                if x1 < x2:
                    theta = math.atan2(x1-x2, y2-y1)
                    Theta[i][1] = theta
                    Theta[j][0] = theta
                else:
                    theta = math.atan2(x2-x1, y1-y2)
                    Theta[i][0] = theta
                    Theta[j][1] = theta

for start, end in Theta:
    delta = end - start
    while delta < 0:
        delta += 2*math.pi
    print(delta/(2*math.pi))

Submission status: Wrong Answer

Solution code:
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
X, Y = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))

X = np.array(X, dtype=np.float128)
Y = np.array(Y, dtype=np.float128)

X -= X.mean()
Y -= Y.mean()


COUNT = 40000

counts = np.zeros(N)
for i in range(10):
    # 角度を決めると確率も決まる
    # 端っこにある2つが50%ずつ
    xs = 10 ** 8
    ys = np.tan(np.linspace(np.pi / 10 * i, np.pi / 10 * (i + 1), COUNT)) * xs
    d = (X[:, None] - xs) ** 2 + (Y[:, None] - ys[None, :]) ** 2
    counts += np.bincount(d.argmin(axis=0), minlength=N) + np.bincount(d.argmax(axis=0), minlength=N)
ans = counts / counts.sum()
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
X, Y = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))

X = np.array(X, dtype=np.float128)
Y = np.array(Y, dtype=np.float128)

COUNT = 40000

counts = np.zeros(N)
for i in range(10):
    # 角度を決めると確率も決まる
    # 端っこにある2つが50%ずつ
    xs = 10 ** 8
    ys = np.tan(np.linspace(np.pi / 10 * i, np.pi / 10 * (i + 1), COUNT)) * xs
    d = (X[:, None] - xs) ** 2 + (Y[:, None] - ys[None, :]) ** 2
    counts += np.bincount(d.argmin(axis=0), minlength=N) + np.bincount(d.argmax(axis=0), minlength=N)
ans = counts / counts.sum()
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
X, Y = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))

X = np.array(X, dtype=np.float128)
Y = np.array(Y, dtype=np.float128)

COUNT = 40000

counts = np.zeros(N)
for i in range(5):
    # 角度を決めると確率も決まる
    # 端っこにある2つが50%ずつ
    xs = 10 ** 8
    ys = np.tan(np.linspace(np.pi / 5 * i, np.pi / 5 * (i + 1), COUNT)) * xs
    d = (X[:, None] - xs) ** 2 + (Y[:, None] - ys[None, :]) ** 2
    counts += np.bincount(d.argmin(axis=0), minlength=N) + np.bincount(d.argmax(axis=0), minlength=N)
ans = counts / counts.sum()
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
import math
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
X, Y = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))

X = np.array(X, dtype=np.float128)
Y = np.array(Y, dtype=np.float128)

COUNT = 40000

# 角度を決めると確率も決まる
# 端っこにある2つが50%ずつ
xs = 10 ** 8
ys = np.tan(np.linspace(0, math.pi, COUNT)) * xs
d = (X[:, None] - xs) ** 2 + (Y[:, None] - ys[None, :]) ** 2
counts = np.bincount(d.argmin(axis=0), minlength=N) + np.bincount(d.argmax(axis=0), minlength=N)
ans = counts / counts.sum()
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
import math
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
X, Y = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))

X = np.array(X, dtype=np.float128)
Y = np.array(Y, dtype=np.float128)


def sides(rad):
    x = 10 ** 8
    y = math.tan(rad) * x
    d = (X - x) ** 2 + (Y - y) ** 2
    return d.argmin(), d.argmax()


COUNT = 50000
counts = np.zeros(N)
# 角度を決めると確率も決まる
# 端っこにある2つが50%ずつ
for rad in np.linspace(0, math.pi, COUNT)[:-1]:
    l, r = sides(rad)
    counts[l] += 1
    counts[r] += 1
ans = counts / counts.sum()
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
import math
from collections import defaultdict


def norm2(vec):
    return math.sqrt(vec[0]**2 + vec[1]**2)


# any 2 points must have different position.
def ConvexHull(point_list):
    pos2idx = {point_list[i]: i for i in range(len(point_list))}
    y_val = defaultdict(list)
    x_list = sorted(list(set([p[0] for p in point_list])))
    for x, y in point_list:
        y_val[x].append(y)

    upper = [(x_list[0], max(y_val[x_list[0]]))]
    lower = [(x_list[0], min(y_val[x_list[0]]))]
    prev = float('inf')
    for xi in x_list[1:]:
        x0, y0 = upper[-1]
        x1, y1 = xi, max(y_val[xi])
        if (y1 - y0) / (x1 - x0) < prev:
            upper.append((x1, y1))
            prev = (y1 - y0) / (x1 - x0)
        else:
            while True:
                x0, y0 = upper[-1]
                if len(upper) == 1:
                    upper.append((x1, y1))
                    break
                x00, y00 = upper[-2]
                if (y1 - y0) / (x1 - x0) > (y1 - y00) / (x1 - x00):
                    upper.pop()
                else:
                    prev = (y1 - y0) / (x1 - x0)
                    upper.append((x1, y1))
                    break

    prev = -float('inf')
    for xi in x_list[1:]:
        x0, y0 = lower[-1]
        x1, y1 = xi, min(y_val[xi])
        if (y1 - y0) / (x1 - x0) > prev:
            lower.append((x1, y1))
            prev = (y1 - y0) / (x1 - x0)
        else:
            while True:
                x0, y0 = lower[-1]
                if len(lower) == 1:
                    lower.append((x1, y1))
                    break
                x00, y00 = lower[-2]
                if (y1 - y0) / (x1 - x0) < (y1 - y00) / (x1 - x00):
                    lower.pop()
                else:
                    prev = (y1 - y0) / (x1 - x0)
                    lower.append((x1, y1))
                    break

    # return upper, lower
    # return [pos2idx[xy] for xy in upper], [pos2idx[xy] for xy in lower]

    upper_idx, lower_idx = [pos2idx[xy] for xy in upper], [pos2idx[xy] for xy in lower]
    if upper_idx[-1] == lower_idx[-1]:
        upper_idx.pop()
    CH_idx = upper_idx
    CH_idx.extend(reversed(lower_idx))
    if CH_idx[0] == CH_idx[-1] and len(CH_idx) > 1:
        CH_idx.pop()
    return CH_idx


N = int(input())
point_list = []
for _ in range(N):
    x, y = map(int, input().split())
    point_list.append((x, y))

CH = ConvexHull(point_list)
if len(CH) == 2:
    print(0.5)
    print(0.5)
    exit()
ans = [0] * N
for i in range(len(CH)):
    s, t, u = CH[i-1], CH[i], CH[(i+1)%len(CH)]
    x0, y0 = point_list[s]
    x1, y1 = point_list[t]
    x2, y2 = point_list[u]
    vec0 = (y0-y1, x1-x0)
    vec1 = (y1-y2, x2-x1)
    ans[t] = math.acos((vec0[0] * vec1[0] + vec0[1] * vec1[1]) / (norm2(vec0) * norm2(vec1))) / (2 * math.pi)

for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
a = []
b = []

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

for _ in range(n):
    x,y = map(int,input().split())
    a.append([x,y])
    b.append([x,y])

#引用 https://qiita.com/kkttm530/items/d6ca372491b75baeac3c
def signed_area(p1, p2, p3):
    '''符号付き面積を計算 '''

    area = (((p2[0] - p1[0]) * (p3[1] - p1[1])) - ((p3[0] - p1[0]) * (p2[1] - p1[1]))) / 2
    return area

def convex_hull(p_list):
    '''グラハムの凸包走査 '''

    p_sort = []
    for i in p_list:
        p_sort.append(i[0])

    # x座標が最小のものをリストの先頭に配置。
    min_index = p_sort.index(min(p_sort))
    min_p = p_list.pop(min_index)
    p_list.insert(0, min_p)

    # 座標最小の点と他の点との角度順にソート ソートアルゴリズムに選択の余地が有る。
    p_length = len(p_list)
    count = 0
    index = 0
    while True:
        count += 1
        index += 1

        area_sign = signed_area(p_list[0], p_list[index], p_list[index + 1])

        # 符号付き面積が負ならば点を入れ替え
        if area_sign < 0:
            p_list[index], p_list[index + 1] = p_list[index + 1], p_list[index]
            count = 0

        if count == p_length - 1:
            break

        if index == p_length - 2:
            index = 0

    # 凹部の点を削除する。
    index = -1
    count = 0
    while True:
        index += 1
        count += 1

        area_sign = signed_area(p_list[index], p_list[index + 1], p_list[index + 2])
        if area_sign < 0:
            del p_list[index + 1]
            count = 0

        if count == len(p_list):
            break

        if index >= len(p_list) - 3:
            index = -1
    return p_list

p = convex_hull(a)
rad = [0]*len(p)

for i in range(len(p)):
    rad[i-1] = math.degrees(math.atan2(p[i][1]-p[i-1][1],p[i][0]-p[i-1][0])) - math.degrees(math.atan2(p[i-1][1]-p[i-2][1],p[i-1][0]-p[i-2][0]))
    rad[i-1] %= 360
    
for i in range(n):
    if b[i] not in p:
        print(0)
    else:
        for j in range(len(p)):
            if p[j] == b[i]:
                print(rad[j]/360)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
a = []
b = []

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

for _ in range(n):
    x,y = map(int,input().split())
    a.append([x,y])
    b.append([x,y])

#引用 https://qiita.com/kkttm530/items/d6ca372491b75baeac3c
def signed_area(p1, p2, p3):
    '''符号付き面積を計算 '''

    area = (((p2[0] - p1[0]) * (p3[1] - p1[1])) - ((p3[0] - p1[0]) * (p2[1] - p1[1]))) / 2
    return area

def convex_hull(p_list):
    '''グラハムの凸包走査 '''

    p_sort = []
    for i in p_list:
        p_sort.append(i[0])

    # x座標が最小のものをリストの先頭に配置。
    min_index = p_sort.index(min(p_sort))
    min_p = p_list.pop(min_index)
    p_list.insert(0, min_p)

    # 座標最小の点と他の点との角度順にソート ソートアルゴリズムに選択の余地が有る。
    p_length = len(p_list)
    count = 0
    index = 0
    while True:
        count += 1
        index += 1

        area_sign = signed_area(p_list[0], p_list[index], p_list[index + 1])

        # 符号付き面積が負ならば点を入れ替え
        if area_sign < 0:
            p_list[index], p_list[index + 1] = p_list[index + 1], p_list[index]
            count = 0

        if count == p_length - 1:
            break

        if index == p_length - 2:
            index = 0

    # 凹部の点を削除する。
    index = -1
    count = 0
    while True:
        index += 1
        count += 1

        area_sign = signed_area(p_list[index], p_list[index + 1], p_list[index + 2])
        if area_sign < 0:
            del p_list[index + 1]
            count = 0

        if count == len(p_list):
            break

        if index >= len(p_list) - 3:
            index = -1
    return p_list

p = convex_hull(a)
rad = [0]*len(p)

for i in range(len(p)):
    rad[i-1] = 180 - math.degrees(math.atan2(p[i-2][1]-p[i-1][1],p[i-2][0]-p[i-1][0])) + math.degrees(math.atan2(p[i][1]-p[i-1][1],p[i][0]-p[i-1][0]))
    rad[i-1] %= 360 

for i in range(n):
    if b[i] not in p:
        print(0)
    else:
        for j in range(len(p)):
            if p[j] == b[i]:
                print(rad[j]/360)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
a = []
b = []

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

for _ in range(n):
    x,y = map(int,input().split())
    a.append([x,y])
    b.append([x,y])

#引用 https://qiita.com/kkttm530/items/d6ca372491b75baeac3c
def signed_area(p1, p2, p3):
    '''符号付き面積を計算 '''

    area = (((p2[0] - p1[0]) * (p3[1] - p1[1])) - ((p3[0] - p1[0]) * (p2[1] - p1[1]))) / 2
    return area


def convex_hull(p_list):
    '''グラハムの凸包走査 '''

    p_sort = []
    for i in p_list:
        p_sort.append(i[0])

    # x座標が最小のものをリストの先頭に配置。
    min_index = p_sort.index(min(p_sort))
    min_p = p_list.pop(min_index)
    p_list.insert(0, min_p)

    # 座標最小の点と他の点との角度順にソート ソートアルゴリズムに選択の余地が有る。
    p_length = len(p_list)
    count = 0
    index = 0
    while True:
        count += 1
        index += 1

        area_sign = signed_area(p_list[0], p_list[index], p_list[index + 1])

        # 符号付き面積が負ならば点を入れ替え
        if area_sign < 0:
            p_list[index], p_list[index + 1] = p_list[index + 1], p_list[index]
            count = 0

        if count == p_length - 1:
            break

        if index == p_length - 2:
            index = 0

    # 凹部の点を削除する。
    index = -1
    count = 0
    while True:
        index += 1
        count += 1

        area_sign = signed_area(p_list[index], p_list[index + 1], p_list[index + 2])
        if area_sign < 0:
            del p_list[index + 1]
            count = 0

        if count == len(p_list):
            break

        if index >= len(p_list) - 3:
            index = -1
    return p_list

p = convex_hull(a)
rad = [0]*len(p)

for i in range(len(p)):
    rad[i-1] = 180 - math.degrees(math.atan2(p[i-2][1]-p[i-1][1],p[i-2][0]-p[i-1][0])) + math.degrees(math.atan2(p[i][1]-p[i-1][1],p[i][0]-p[i-1][0]))
    if rad[i-1] >= 360:
        rad[i-1] -= 360

for i in range(n):
    if b[i] not in p:
        print(0)
    else:
        for j in range(len(p)):
            if p[j] == b[i]:
                print(rad[j]/360)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

import numpy as np
from numpy import pi
N = int(input())
X,Y = np.array([input().split() for _ in range(N)],dtype=np.float64).T

# ひとつずつ計算する。垂直二等分線のどっちか側。
# 半平面の共通部分

def solve(i):
    Xother = np.delete(X,i)
    Yother = np.delete(Y,i)
    angle = np.arctan2(Y[i]-Yother,X[i]-Xother) # 半平面の中心線
    # 下半平面との共通部分、主値で持つ
    case1 = (angle<=-pi/2)
    case2 = (-pi/2<=angle)&(angle<=pi/2)
    case3 = (pi/2<=angle)
    lower_left = np.zeros_like(angle)
    lower_left[case1] = -pi
    lower_left[case2] = angle[case2]-pi/2
    lower_left[case3] = -pi/2

    lower_right = np.zeros_like(angle)
    lower_right[case1] = angle[case1]+pi/2
    lower_right[case2] = 0
    lower_right[case3] = angle[case3]+pi/2-2*pi
    
    upper_left = np.zeros_like(angle)
    upper_left[case1] = angle[case1]+3*pi/2
    upper_left[case2] = 0
    upper_left[case3] = angle[case3]-pi/2
    
    upper_right = np.zeros_like(angle)
    upper_right[case1] = pi
    upper_right[case2] = angle[case2] + pi/2
    upper_right[case3] = pi
    
    p_upper = max(0,upper_right.min()-upper_left.max())/(2*pi)
    p_lower = max(0,lower_right.min()-lower_left.max())/(2*pi)
    return p_upper+p_lower

answer = [solve(i) for i in range(N)]
print(*answer,sep='\n')