結果

問題 No.2632 Center of Three Points in Lp Norm
ユーザー 👑 tatyamtatyam
提出日時 2024-02-12 07:49:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 80,092 KB
最終ジャッジ日時 2024-02-12 09:19:17
合計ジャッジ時間 11,897 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 198 ms
78,256 KB
testcase_01 AC 166 ms
76,964 KB
testcase_02 AC 172 ms
76,964 KB
testcase_03 AC 329 ms
79,608 KB
testcase_04 AC 328 ms
79,076 KB
testcase_05 WA -
testcase_06 AC 258 ms
77,824 KB
testcase_07 AC 189 ms
78,140 KB
testcase_08 AC 182 ms
77,056 KB
testcase_09 AC 265 ms
77,424 KB
testcase_10 AC 347 ms
79,224 KB
testcase_11 AC 311 ms
78,080 KB
testcase_12 AC 163 ms
77,964 KB
testcase_13 AC 257 ms
78,588 KB
testcase_14 AC 174 ms
77,960 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 205 ms
78,436 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 169 ms
78,104 KB
testcase_21 AC 165 ms
77,468 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 215 ms
78,652 KB
testcase_26 AC 164 ms
77,556 KB
testcase_27 AC 167 ms
77,088 KB
testcase_28 WA -
testcase_29 AC 175 ms
76,964 KB
testcase_30 AC 160 ms
77,076 KB
testcase_31 AC 158 ms
77,084 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 165 ms
78,480 KB
testcase_35 WA -
testcase_36 AC 205 ms
79,828 KB
testcase_37 AC 236 ms
77,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import random
import math

def norm(x: float, y: float) -> float:
    x = abs(x)
    y = abs(y)
    if x > y:
        x, y = y, x
    if y == 0.0:
        return 0.0
    x /= y
    return pow(1.0 + pow(x, p), 1 / p) * y

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

get = lambda: list(map(float, input().split()))
p = float(input())
a = get()
b = get()
c = get()

def f(o) -> float:
    D = [dist(a, o), dist(b, o), dist(c, o)]
    D.sort()
    return D[2] - x * D[0]

o = [0.0, 0.0]
d = 1.0
R = 1e-15
T = int(1e5)
r = R ** (10 / T)

for _ in range(T):
    x = _ / T
    theta = (random.random() * 2.0 - 1.0) * math.pi
    while True:
        o2 = [o[0] + d * math.cos(theta), o[1] + d * math.sin(theta)]
        if f(o2) >= f(o):
            break
        o = o2
        d /= r
    d *= r

print(*o)
print(dist(a, o), dist(b, o), dist(c, o), file=open(2, "w"))
0