結果

問題 No.764 浮動点
ユーザー mkawa2mkawa2
提出日時 2022-02-05 11:27:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 35 ms / 1,500 ms
コード長 3,493 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 11,388 KB
実行使用メモリ 9,328 KB
最終ジャッジ日時 2023-09-02 06:31:10
合計ジャッジ時間 3,123 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
9,068 KB
testcase_01 AC 19 ms
8,956 KB
testcase_02 AC 19 ms
8,892 KB
testcase_03 AC 22 ms
8,468 KB
testcase_04 AC 30 ms
8,996 KB
testcase_05 AC 24 ms
9,008 KB
testcase_06 AC 31 ms
9,088 KB
testcase_07 AC 24 ms
8,544 KB
testcase_08 AC 32 ms
9,128 KB
testcase_09 AC 25 ms
9,020 KB
testcase_10 AC 33 ms
8,920 KB
testcase_11 AC 25 ms
9,112 KB
testcase_12 AC 34 ms
9,080 KB
testcase_13 AC 34 ms
9,084 KB
testcase_14 AC 34 ms
9,248 KB
testcase_15 AC 34 ms
9,264 KB
testcase_16 AC 34 ms
9,316 KB
testcase_17 AC 35 ms
9,328 KB
testcase_18 AC 33 ms
9,124 KB
testcase_19 AC 32 ms
9,088 KB
testcase_20 AC 35 ms
9,184 KB
testcase_21 AC 35 ms
9,144 KB
testcase_22 AC 32 ms
8,972 KB
testcase_23 AC 33 ms
8,852 KB
testcase_24 AC 35 ms
9,112 KB
testcase_25 AC 21 ms
8,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = (1 << 63)-1
inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

from math import *

# init_x, init_yは始線
class Vector:
    def __init__(self, x, y, init_x=1, init_y=0):
        self.x = x
        self.y = y
        self.norm2 = x*x+y*y
        self.norm = self.norm2**0.5
        self.zone = 2
        if x == y == 0: self.zone = -1
        elif init_x*y-init_y*x > 0: self.zone = 1
        elif init_x*y-init_y*x < 0: self.zone = 3
        elif init_x*x+init_y*y > 0: self.zone = 0

    def __repr__(self):
        return "({},{})".format(self.x, self.y)

    def __eq__(self, other):
        if self.zone != other.zone: return False
        return self.outer(other) == 0

    def __lt__(self, other):
        if self.zone == other.zone: return self.outer(other) > 0
        return self.zone < other.zone

    def __add__(self, other): return Vector(self.x+other.x, self.y+other.y)

    def __sub__(self, other): return Vector(self.x-other.x, self.y-other.y)

    def __iadd__(self, other):
        self.x += other.x
        self.y += other.y
        return self

    def __isub__(self, other):
        self.x -= other.x
        self.y -= other.y
        return self

    def __neg__(self):
        return Vector(-self.x, -self.y)

    def __mul__(self, val):
        return Vector(val*self.x, val*self.y)

    __rmul__ = __mul__

    def __truediv__(self, val):
        assert val != 0
        return Vector(self.x/val, self.y/val)

    def dot(self, v): return self.x*v.x+self.y*v.y

    def outer(self, v): return self.x*v.y-self.y*v.x

    def rot90(self): return Vector(-self.y, self.x)

# Circle(r,Vector) or Circle(r,x,y)
class Circle:
    def __init__(self, r, vx, oy=None):
        if not isinstance(vx, Vector): vx = Vector(vx, oy)
        self.o, self.r = vx, r

def common_part(c1, c2):
    if c1.r < c2.r: c1, c2 = c2, c1
    r1, o1 = c1.r, c1.o
    r2, o2 = c2.r, c2.o
    d = (o2-o1).norm
    d2 = (o2-o1).norm2
    if d >= r1+r2: return 0
    if r1 >= r2+d: return r2*r2*pi
    rad1 = acos((r1**2+d2-r2**2)/2/r1/d)
    rad2 = acos((r2**2+d2-r1**2)/2/r2/d)
    return r1*r1*(rad1-sin(rad1*2)/2)+r2*r2*(rad2-sin(rad2*2)/2)

def radius(ll):
    aa = [0]*(len(ll)-1)
    bb = [0]*(len(ll)-1)
    s = m = 0
    for i, l in enumerate(ll[:-1]):
        s += l
        m = max(m, l)
        aa[i] = s
        bb[i] = max(0, 2*m-s)
    return aa, bb

n = II()
x = II()
ll = [II() for _ in range(n+1)]

aa, bb = radius(ll)
pp, qq = radius(ll[::-1])
pp.reverse()
qq.reverse()
# pDB(aa)
# pDB(bb)
# pDB(pp)
# pDB(qq)

for a, b, p, q in zip(aa, bb, pp, qq):
    if a == b or p == q:
        print(0)
        continue
    l1 = Circle(a, 0, 0)
    l2 = Circle(b, 0, 0)
    r1 = Circle(p, x, 0)
    r2 = Circle(q, x, 0)
    ans = common_part(l1, r1)-common_part(l1, r2)-common_part(l2, r1)+common_part(l2, r2)
    print(ans)
0