結果

問題 No.2632 Center of Three Points in Lp Norm
ユーザー suisensuisen
提出日時 2024-02-16 23:44:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,096 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 73,316 KB
最終ジャッジ日時 2024-02-16 23:44:42
合計ジャッジ時間 6,552 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
73,188 KB
testcase_01 WA -
testcase_02 AC 83 ms
73,184 KB
testcase_03 AC 83 ms
73,180 KB
testcase_04 AC 83 ms
73,188 KB
testcase_05 AC 84 ms
73,184 KB
testcase_06 AC 85 ms
73,180 KB
testcase_07 AC 84 ms
73,184 KB
testcase_08 AC 85 ms
73,180 KB
testcase_09 AC 83 ms
73,188 KB
testcase_10 AC 85 ms
73,180 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 84 ms
73,188 KB
testcase_14 WA -
testcase_15 AC 83 ms
73,180 KB
testcase_16 AC 83 ms
73,184 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 84 ms
73,184 KB
testcase_21 AC 84 ms
73,180 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 87 ms
73,180 KB
testcase_25 WA -
testcase_26 AC 85 ms
73,180 KB
testcase_27 AC 85 ms
73,188 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 86 ms
73,188 KB
testcase_31 AC 84 ms
73,188 KB
testcase_32 AC 84 ms
73,180 KB
testcase_33 AC 89 ms
73,184 KB
testcase_34 AC 71 ms
70,520 KB
testcase_35 AC 83 ms
73,180 KB
testcase_36 AC 83 ms
73,180 KB
testcase_37 AC 83 ms
73,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Fp = float

p = Fp(input())
ax, ay = map(Fp, input().split())
bx, by = map(Fp, input().split())
cx, cy = map(Fp, input().split())

t = Fp(2) / (Fp(3) + Fp(5) ** (Fp(1) / Fp(2)))

def norm(x1: Fp, y1: Fp, x2: Fp, y2: Fp):
    return (abs(x1 - x2) ** p + abs(y1 - y2) ** p) ** (Fp(1) / p)

def max_norm(x: Fp, y: Fp):
    a = norm(x, y, ax, ay)
    b = norm(x, y, bx, by)
    c = norm(x, y, cx, cy)
    return abs(a - b) ** 2 + abs(b - c) ** 2 + abs(c - a) ** 2

def bsearch_y(x: Fp):
    ly, ry = Fp(-1000000), Fp(1000000)
    for _ in range(100):
        mly = ly + t * (ry - ly)
        mry = ry - t * (ry - ly)

        if max_norm(x, mly) > max_norm(x, mry):
            ly = mly
        else:
            ry = mry
    
    return max_norm(x, ly), ly

def bsearch_x():
    lx, rx = Fp(-1000000), Fp(1000000)
    for _ in range(100):
        mlx = lx + t * (rx - lx)
        mrx = rx - t * (rx - lx)

        if bsearch_y(mlx)[0] > bsearch_y(mrx)[0]:
            lx = mlx
        else:
            rx = mrx
    
    return lx, bsearch_y(lx)[1]

x, y = bsearch_x()
print(f'{x:.20f} {y:.20f}')

0