結果

問題 No.2632 Center of Three Points in Lp Norm
ユーザー tassei903tassei903
提出日時 2024-02-13 06:08:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 229 ms / 2,000 ms
コード長 2,121 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 77,964 KB
最終ジャッジ日時 2024-02-13 06:08:39
合計ジャッジ時間 11,863 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 209 ms
77,484 KB
testcase_01 AC 171 ms
76,696 KB
testcase_02 AC 179 ms
76,572 KB
testcase_03 AC 191 ms
77,484 KB
testcase_04 AC 195 ms
77,020 KB
testcase_05 AC 200 ms
77,040 KB
testcase_06 AC 182 ms
77,260 KB
testcase_07 AC 207 ms
77,632 KB
testcase_08 AC 169 ms
76,700 KB
testcase_09 AC 218 ms
77,316 KB
testcase_10 AC 208 ms
77,612 KB
testcase_11 AC 179 ms
77,452 KB
testcase_12 AC 213 ms
77,616 KB
testcase_13 AC 183 ms
77,452 KB
testcase_14 AC 228 ms
77,628 KB
testcase_15 AC 188 ms
77,508 KB
testcase_16 AC 209 ms
77,612 KB
testcase_17 AC 226 ms
77,616 KB
testcase_18 AC 210 ms
77,632 KB
testcase_19 AC 208 ms
77,480 KB
testcase_20 AC 196 ms
77,432 KB
testcase_21 AC 213 ms
77,804 KB
testcase_22 AC 207 ms
77,456 KB
testcase_23 AC 219 ms
77,604 KB
testcase_24 AC 203 ms
77,316 KB
testcase_25 AC 222 ms
77,628 KB
testcase_26 AC 221 ms
77,552 KB
testcase_27 AC 214 ms
77,780 KB
testcase_28 AC 199 ms
77,024 KB
testcase_29 AC 189 ms
77,476 KB
testcase_30 AC 191 ms
77,380 KB
testcase_31 AC 174 ms
76,876 KB
testcase_32 AC 171 ms
76,964 KB
testcase_33 AC 129 ms
76,060 KB
testcase_34 AC 229 ms
77,964 KB
testcase_35 AC 146 ms
76,560 KB
testcase_36 AC 203 ms
77,592 KB
testcase_37 AC 166 ms
76,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes")
no = lambda :print("no");No = lambda :print("No")
#######################################################################

def sub(a, b):
    return (a[0] - b[0], a[1] - b[1])

def norm(a) -> float:
    x = abs(a[0])
    y = abs(a[1])
    if x > y:
        x, y = y, x
    if y == 0.0:
        return 0.0
    x /= y
    if pow(x, p + 2) < 1e-18:
        return (1.0 + pow(x, p) / p) * y
    return pow(1.0 + pow(x, p), 1 / p) * y

def dist(a, b):
    return norm(sub(a, b))

p = float(input())
a = na()
b = na()
c = na()

def f(a, b, c):
    flag = 0

    if a[0] == b[0]:
        a = (a[1], a[0])
        b = (b[1], b[0])
        c = (c[1], c[0])
        flag = 1

    uy = 10**6
    ly = -10**6

    if a[0] > b[0]:
        right = a
        left = b
    else:
        right = b
        left = a

    def f(left, right, my):
        ux = 10**10
        lx = -10**10
        for _ in range(200):
            mx = (ux + lx) / 2
            if dist(left, (mx, my)) > dist(right, (mx, my)):
                ux = mx
            else:
                lx = mx
        return ux

    x = f(left, right, uy)
    #print(x, uy)

    if dist(c, (x, uy)) < dist(left, (x, uy)):
        up = c
        down = left
    else:
        up = left
        down = c
    #print(up, down, left, right)
    #print(dist(up, (x, uy)), dist(down, (x, uy)), dist(up, (f(left, right, uy), uy)), dist(down, (f(left, right, uy), uy)))

    for _ in range(200):
        my = (uy + ly) / 2
        x = f(left, right, my)
        if dist(up, (x, my)) < dist(down, (x, my)):
            uy = my
        else:
            ly = my

    ox, oy = f(left, right, uy), uy
    D = max(dist(a, (ox, oy)) , dist(b, (ox, oy)) , dist(c, (ox, oy)))
    if flag:
        ox, oy = oy, ox
    return D, ox, oy
ans, OX, OY = 10**18, 0, 0
for _ in range(3):
    D, ox, oy = f(a, b, c)
    #print(D, ox, oy)
    if D < ans:
        ans = D
        OX, OY = ox, oy
    a,b,c = b,c,a
print(OX, OY)
0