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: Accepted

Solution code:
import math

# ベクトル[p0->p1]に対する、点p2の位置（反時計回りならば、プラスを返す）
def ccw(p0, p1, p2):
    return (p1[0] - p0[0]) * (p2[1] - p0[1]) - (p1[1] - p0[1]) * (p2[0] - p0[0])


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

# 凸包を求める
pts.sort()

chU = [] # 上側
for pt, i in pts:
    while len(chU) >= 2 and ccw(chU[-2][0], chU[-1][0], pt) >= 0:
        chU.pop()
    chU.append((pt, i))

chL = [] # 下側
for pt, i in reversed(pts):
    while len(chL) >= 2 and ccw(chL[-2][0], chL[-1][0], pt) >= 0:
        chL.pop()
    chL.append((pt, i))

CH = chU[:-1] + chL[:-1] # ((x, y), i)


# 各点に対して、凸包上で隣接する２点との垂直二等分線がなす角度を求める（360°に対して占める割合が答え）
# （隣接する２辺の傾斜角の差に等しいので、それを計算する）
aIn = math.atan2(CH[-1][0][1] - CH[0][0][1], CH[-1][0][0] - CH[0][0][0])
ptNow = CH[-1][0]
anss = [0.0] * N
for i in reversed(range(len(CH))):
    iNow = CH[i][1]
    pt2 = CH[i - 1][0]
    aOut = math.atan2(pt2[1] - ptNow[1], pt2[0] - ptNow[0])
    anss[iNow] = ((aOut - aIn) % (2 * math.pi)) / (2 * math.pi)

    ptNow = pt2
    aIn = aOut

for ans in anss:
    print(ans)

Submission status: Accepted

Solution code:
from math import atan2,pi

N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]
ptoi = {}
for i,p in enumerate(src):
    ptoi[p] = i

if N == 2:
    for i in range(2): print(0.5)
    exit()

#ref https://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain
def convex_hull(ps):
    ps.sort()
    def cross(o,a,b):
        return (a[0]-o[0]) * (b[1]-o[1]) - (a[1]-o[1]) * (b[0]-o[0])
    lower = []
    for p in ps:
        while len(lower) >= 2 and cross(lower[-2], lower[-1], p) <= 0:
            lower.pop()
        lower.append(p)
    upper = []
    for p in reversed(ps):
        while len(upper) >= 2 and cross(upper[-2], upper[-1], p) <= 0:
            upper.pop()
        upper.append(p)
    return lower[:-1] + upper[:-1]

outer = convex_hull(src)
outer += outer[:2]

ans = [0] * N
for (y1,x1),(y2,x2),(y3,x3) in zip(outer,outer[1:],outer[2:]):
    dy1,dx1 = y2-y1,x2-x1
    dy2,dx2 = y3-y2,x3-x2
    ang1 = atan2(dx1, dy1)
    ang2 = atan2(dx2, dy2)
    a = (ang2 - ang1) % (pi*2) / (pi*2)
    ans[ptoi[(y2,x2)]] = a

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
from math import atan2, degrees

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

for x, y in holes:
    slopes = []
    for x2, y2 in holes:
        if x == x2 and y == y2: continue
        slopes += [degrees(atan2(y2 - y, x2 - x))]

    aRange = [(0, 360)]
    for slope in slopes:
        f1 = (slope + 90) % 360
        t1 = (slope - 90) % 360
        if t1 == 0: t1 = 360

        if f1 <= t1:
            fts = [(f1, t1)]
        else:
            fts = [(0, t1), (f1, 360)]

        aRange2 = []
        for f, t in fts:
            for aFr, aTo in aRange:
                if aFr <= f: aFr = f
                if t <= aTo: aTo = t
                if aFr <= aTo:
                    aRange2 += [(aFr, aTo)]
        aRange = aRange2

    ans = 0
    for aFr, aTo in aRange:
        ans += (aTo - aFr) / 360
    print(ans)

Submission status: Accepted

Solution code:
import math
import random
N = int(input())
X = []
Y = []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
suma = 0
for i in range(N):
    r = []
    for j in range(N):
        if i == j:
            continue
        r.append(math.atan2(Y[j] - Y[i], X[j] - X[i]))
    r.sort()
    dr = [r[i + 1] - r[i] for i in range(len(r) - 1)]
    dr.append(r[0] + 2 * math.pi - r[-1])
    print((max(dr) - math.pi) / (2 * math.pi) if max(dr) > math.pi else 0)

Submission status: Accepted

Solution code:
from collections import Counter
import numpy as np

p = 2.5e5
n = int(input())
l = np.array([list(map(int, input().split())) for _ in range(n)], dtype=np.float32)
ans = np.zeros(n)

a = np.linspace(0, 2 * np.pi, p, endpoint=False)
b = np.array([np.sin(a), np.cos(a)], dtype=np.float32)

for i, v in Counter(np.argmax(np.dot(l, b), axis=0)).items():
  ans[i] += v / p

print('\n'.join(map(str, ans)))

Submission status: Accepted

Solution code:
from collections import Counter
import numpy as np


def part(s, t):
    a = np.linspace(s, t, 1e5, endpoint=False)
    for i, v in Counter(np.argmax(np.dot(pts, [np.sin(a), np.cos(a)]), axis=0)).items():
        ans[i] += v


n = int(input())
pts = [list(map(int, input().split())) for _ in range(n)]
ans = np.zeros(n)
part(0, np.pi)
part(np.pi, 2 * np.pi)
ans /= 2e5
print('\n'.join(map(str, ans)))

Submission status: Accepted

Solution code:
from collections import Counter
import numpy as np


def part(pts, s, t, num, ans):
    a = np.linspace(s, t, num, endpoint=False)
    for i, v in Counter(np.argmax(np.dot(pts, [np.sin(a), np.cos(a)]), axis=0)).items():
        ans[i] += v


def solve(n, pts):
    ans = np.zeros(n)
    part(pts, 0, np.pi, 1e5, ans)
    part(pts, np.pi, 2 * np.pi, 1e5, ans)
    return ans / 2e5


n = int(input())
print('\n'.join(map(str, solve(n, [list(map(int, input().split())) for _ in range(n)]))))

Submission status: Accepted

Solution code:
from collections import Counter

import numpy as np


def part(pts, a, ans):
    b = np.dot(pts, [np.sin(a), np.cos(a)])
    c = np.argmax(b, axis=0)
    for i, v in Counter(c).items():
        ans[i] += v


def solve(n, pts):
    ans = [0] * n
    part(pts, np.linspace(0, np.pi, 100000, endpoint=False), ans)
    part(pts, np.linspace(np.pi, 2 * np.pi, 100000, endpoint=False), ans)
    return [v / 200000 for v in ans]


n = int(input())
pts = np.array([list(map(int, input().split())) for _ in range(n)])
print('\n'.join(map(str, solve(n, pts))))

Submission status: Accepted

Solution code:
import numpy as np
from scipy.spatial import ConvexHull
from scipy.spatial.qhull import QhullError


def solve(n, pts):
    ans = [0] * n

    try:
        hull = ConvexHull(pts)
    except QhullError:
        lm = np.argmin(pts, axis=0)
        rm = np.argmax(pts, axis=0)
        if lm[0] != rm[0]:
            l, r = lm[0], rm[0]
        elif lm[1] != rm[0]:
            l, r = lm[1], rm[0]
        else:
            l, r = lm[0], rm[1]
        ans[l] = ans[r] = 0.5
        return ans

    ps = np.array(list(map(pts.__getitem__, hull.vertices)))
    vs = ps - np.roll(ps, 1, axis=0)

    vt = vs.T
    vt[0] *= -1
    arcs = np.arctan2(*vt)
    arcs = np.append(arcs, arcs[0])
    da = np.diff(arcs) / (2 * np.pi) % 1

    for i, a in zip(hull.vertices, da):
        ans[i] = a

    return ans


n = int(input())
pts = [list(map(int, input().split())) for _ in range(n)]
print('\n'.join(map(str, solve(n, pts))), end='')

Submission status: Accepted

Solution code:
#! -*- coding: utf-8 -*-

import numpy as np

n = int(raw_input())
p = np.zeros([n,2],dtype=int)
for i in range(n):
    p[i] = map(int,raw_input().split())

#print p

s = np.zeros([n])

for i in range(n):
    katamuki = np.zeros([n])
    for j in range(n):
        if not i == j:
            vec = np.array([p[j][0]-p[i][0],p[j][1]-p[i][1]])
            xvec = np.array([1,0])
            katamuki[j] = np.arccos((np.dot(xvec,vec))/(np.linalg.norm(vec)))
        if p[j][1]-p[i][1] < 0:
            katamuki[j] = 2*np.pi - katamuki[j]
    #print katamuki
    katamuki = np.sort(katamuki)
    for j in range(n-1):
        if j == 0:
            kakudo = katamuki[1]+(2*np.pi-katamuki[n-1])
        else:
            kakudo = katamuki[j+1]-katamuki[j]
        if kakudo > np.pi:
            s[i] = kakudo-np.pi

#print s
ans = s / (2*np.pi)
#print ans
for line in ans:
    print line

Submission status: Accepted

Solution code:
from sys import exit, stderr, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect
from math import atan2, pi

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

p = []

N = read()

for _ in range(N):
  (x, y) = reads()
  p.append((x, y))

for i in range(N):
  (x, y) = p[i]
  (b1, e1) = (0, pi)
  (b2, e2) = (pi, 2*pi)

  for j in range(N):
    if j == i:
      continue

    (z, w) = p[j]
    th = (atan2(w - y, z - x) + pi / 2) % (2*pi)

    if th <= pi:
      b1 = max(b1, th)
      e2 = min(e2, th + pi)
    else:
      e1 = min(e1, th - pi)
      b2 = max(b2, th)
  result = (max(0, e1-b1) + max(0, e2-b2)) / 2 / pi
  print("{:.20f}".format(result))

Submission status: Accepted

Solution code:
import math

N=int(input())

PI = math.pi

X=[]
Y=[]
for i in range(N):
    x,y=[int(i) for i in input().split()]
    X.append(x)
    Y.append(y)

for i in range(N):
    kakudo = [math.atan2(Y[i]-Y[j],X[i]-X[j]) for j in range(N) if j != i]
    kakudo.sort()
#    print(kakudo)
    kmax = 0
    if N == 2:
        kmax = 2*PI
    else:
        for j in range(N-2):
            kmax = max(kmax,kakudo[j+1] - kakudo[j])
            kmax = max(kmax, kakudo[0] + 2*PI - kakudo[N-2])
    print(max(0,kmax-PI)/(2*PI))

#print(math.atan2(0,0))

Submission status: Accepted

Solution code:
import math
from math import pi

def solve(rng_lst, N):
    pos_lst = [] # (pos, opp, isStart)
    for rng in rng_lst:
        pos_lst.append((rng[0], rng[2], True))
        pos_lst.append((rng[1], rng[2], False))
    pos_lst = sorted(pos_lst, key=lambda x: x[0])
    
    ans = 0
    opp_lst = []
    prv = 0
    for pos in pos_lst:
        if pos[2]: # if start
            opp_lst.append(pos[1])
        else: # if end
            if len(opp_lst) == N - 1:
                ans += (pos[0] - prv)
            opp_lst.remove(pos[1])
        prv = pos[0]
    return ans/(2*pi)

N = int(input())
x_lst = []
y_lst = []
for _ in range(N):
    x, y = [int(_) for _ in input().split()]
    x_lst.append(x)
    y_lst.append(y)
    
for i in range(N):
    rng_lst = [] #list of (stt, end, opp)
    for j in range(N):
        if i != j:
            xi = x_lst[i]
            yi = y_lst[i]
            xj = x_lst[j]
            yj = y_lst[j]
            
            if yi == yj:
                if (xi < xj):
                    rng_lst.append((pi / 2,  pi / 2 + pi, j))
                else:
                    rng_lst.append((0, pi / 2, j))
                    rng_lst.append((pi / 2 + pi, 2 * pi, j))
            else:
                k = - (xj - xi) / (yj - yi)
                xii = xi - (xi + xj)/2
                yii = yi - (yi + yj)/2
                at = math.atan(k)

                if at >= 0 and yii < k * xii:
                    rng_lst.append((0, at, j))
                    rng_lst.append((pi + at, 2 * pi, j))
                elif at >= 0 and yii > k * xii:
                    rng_lst.append((at, pi + at, j))
                elif at < 0 and yii < k * xii:
                    rng_lst.append((pi + at, 2 * pi + at, j))
                elif at < 0 and yii > k * xii:
                    rng_lst.append((0, pi + at, j))
                    rng_lst.append((2 * pi + at, 2 * pi, j))
                else:
                    print(k, xii, yii, at)
                    assert 0 == 1
    print(solve(rng_lst, N))

Submission status: Accepted

Solution code:
from math import atan2, pi
n = int(raw_input())
a = [map(int, raw_input().split()) for _ in xrange(n)]
for i in xrange(n):
    x, y = a[i]
    p = []
    for j in xrange(n):
        if i == j:
            continue
        nx, ny = a[j]
        t = atan2(y - ny, x - nx)
        if t - pi / 2 < -pi:
            p.append((-pi, 1))
            p.append((t + pi / 2, -1))
            p.append((t - pi / 2 + 2 * pi, 1))
            p.append((pi, -1))
        elif t + pi / 2 > pi:
            p.append((-pi, 1))
            p.append((t + pi / 2 - 2 * pi, -1))
            p.append((t - pi / 2, 1))
            p.append((pi, -1))
        else:
            p.append((t - pi / 2, 1))
            p.append((t + pi / 2, -1))
    p.sort()
    pv = -pi
    tot = 0
    c = 0
    for x, y in p:
        if c == n - 1:
            tot += x - pv
        c += y
        pv = x
    print "%.12f" % (tot / 2 / pi,)

Submission status: Accepted

Solution code:
MIS = lambda: map(int,input().split())
from math import acos

def ccw(p1, p2, p3):
    # positive -> ccw; negative -> cw; 0 -> collinear
    return (p2[0]-p1[0])*(p3[1]-p1[1]) - (p2[1]-p1[1])*(p3[0]-p1[0])

def ConvexHull(p):
    U = []; L = []; p.sort()
    for q in p:
        while len(U)>1 and ccw(U[-2], U[-1], q) >= 0: U.pop()
        while len(L)>1 and ccw(L[-2], L[-1], q) <= 0: L.pop()
        U.append(q); L.append(q)
    return U + L[-2:0:-1]

def angle(v1, v2):
    inner = v1[0]*v2[0] + v1[1]*v2[1]
    v1s = (v1[0]**2 + v1[1]**2) ** .5
    v2s = (v2[0]**2 + v2[1]**2) ** .5
    return acos(inner / v1s / v2s)

n = int(input())
if n == 1: print(1); exit()
if n == 2: print(0.5); print(0.5); exit()

p = [tuple(MIS())+(i,) for i in range(n)]
CH = ConvexHull(p)
bsc = []
for i in range(len(CH)):
    x1, y1, i1 = CH[i]
    x2, y2, i2 = CH[i-1]
    bsc.append((y1-y2, x2-x1))
if len(CH) == 2: angles = [1, 1]
else: angles = [angle(bsc[i], bsc[i-1]) for i in range(len(CH))]
S = sum(angles)

ans = [0] * n
for i in range(len(CH)):
    x, y, ind = CH[i-1]
    ans[ind] = angles[i] / S
for x in ans: print(x)

Submission status: Runtime Error

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

def examB():
    # 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

    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
    P.sort(key=lambda x:x[1])
    P.sort()
    C = ConvexHull(P)
    n = len(C)
    ans = [0]*N
    if len(C)==2:
        for c in C:
            ans[D[c]] = 0.5
        for v in ans:
            print(v)
        return
    #print(C)
    for i,c in enumerate(C):
        cur = calc_deg(P[c],P[C[i-1]],P[C[i-n+2]])
        #print(cur,math.degrees(math.acos(cur)))
        #print(cur,P[c],D[P[c]])
        ans[D[P[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:
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    # 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

    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
    P.sort(key=lambda x:x[1])
    P.sort()
    C = ConvexHull(P)
    ans = [0]*N
    if len(C)==2:
        for c in C:
            ans[D[c]] = 0.5
        for v in ans:
            print(v)
        return
    #print(C)
    for i,c in enumerate(C):
        cur = calc_deg(P[c],P[C[i-1]],P[C[i-N+2]])
        #print(cur,math.degrees(math.acos(cur)))
        #print(cur,P[c],D[P[c]])
        ans[D[P[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:
def examA():
    N = I()
    ans = 0
    print(ans)
    return

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

    # ps = [(x, y), ...]: ソートされた座標list
    def convex_hull(ps):
        qs = []
        N = len(ps)
        for p in ps:
            # 一直線上で高々2点にする場合は ">=" にする
            while len(qs) > 1 and cross3(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 cross3(qs[-1], qs[-2], p) > 0:
                qs.pop()
            qs.append(p)
        return qs
    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
    P.sort(key=lambda x:x[1])
    P.sort()
    C = convex_hull(P)
    ans = [0]*N
    if len(C)==3:
        for c in C:
            ans[D[c]] = 0.5
        for v in ans:
            print(v)
        return
    del C[-1]
    #print(C)
    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
"""