結果

問題 No.2632 Center of Three Points in Lp Norm
ユーザー 👑 tatyamtatyam
提出日時 2024-02-16 22:41:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,776 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-02-16 22:42:28
合計ジャッジ時間 5,799 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
10,240 KB
testcase_01 AC 69 ms
10,240 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 65 ms
10,240 KB
testcase_05 AC 64 ms
10,240 KB
testcase_06 AC 63 ms
10,240 KB
testcase_07 WA -
testcase_08 AC 63 ms
10,240 KB
testcase_09 WA -
testcase_10 AC 63 ms
10,240 KB
testcase_11 WA -
testcase_12 AC 64 ms
10,240 KB
testcase_13 WA -
testcase_14 AC 63 ms
10,240 KB
testcase_15 AC 63 ms
10,240 KB
testcase_16 AC 70 ms
10,240 KB
testcase_17 AC 64 ms
10,240 KB
testcase_18 AC 72 ms
10,240 KB
testcase_19 AC 65 ms
10,240 KB
testcase_20 AC 65 ms
10,240 KB
testcase_21 WA -
testcase_22 AC 63 ms
10,240 KB
testcase_23 AC 65 ms
10,240 KB
testcase_24 AC 65 ms
10,240 KB
testcase_25 AC 64 ms
10,240 KB
testcase_26 WA -
testcase_27 AC 70 ms
10,240 KB
testcase_28 AC 61 ms
10,240 KB
testcase_29 AC 64 ms
10,240 KB
testcase_30 AC 63 ms
10,240 KB
testcase_31 AC 65 ms
10,240 KB
testcase_32 AC 65 ms
10,240 KB
testcase_33 AC 66 ms
10,240 KB
testcase_34 AC 64 ms
10,240 KB
testcase_35 AC 82 ms
10,240 KB
testcase_36 AC 64 ms
10,240 KB
testcase_37 AC 82 ms
10,240 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])
    return x ** p + y ** p

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(100):
            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)

    if dist(c, (x, uy)) < dist(left, (x, uy)):
        up = c
        down = left
    else:
        up = left
        down = c

    for _ in range(100):
        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