結果

問題 No.2632 Center of Three Points in Lp Norm
ユーザー NyaanNyaanNyaanNyaan
提出日時 2024-02-16 23:18:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,101 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 73,648 KB
最終ジャッジ日時 2024-02-16 23:19:40
合計ジャッジ時間 17,816 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,740 ms
66,972 KB
testcase_01 AC 1,744 ms
66,932 KB
testcase_02 AC 1,730 ms
66,916 KB
testcase_03 WA -
testcase_04 AC 1,736 ms
66,972 KB
testcase_05 AC 1,669 ms
66,972 KB
testcase_06 AC 1,691 ms
66,908 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import scipy
import time
import random

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

dx = (ax + bx + cx) / 3
dy = (ay + by + cy) / 3

def my_pow(x):
    return np.abs(x) ** p

def f(point):
    x, y = point
    anorm = my_pow(ax - x) + my_pow(ay - y)
    bnorm = my_pow(bx - x) + my_pow(by - y)
    cnorm = my_pow(cx - x) + my_pow(cy - y)
    return max(anorm, bnorm, cnorm) - min(anorm, bnorm, cnorm)


start = time.time()

ans = []
best = 1e9

def check(X, Y):
    global ans, best
    cur = scipy.optimize.fmin(f, [X, Y], disp=False, maxiter=500, ftol=1e-7)
    if f(cur) < best:
        ans = cur
        best = f(cur)


for scale in range(0, 7):
    for X in [-(10**scale), 10**scale]:
        for Y in [-(10**scale), 10**scale]:
            check(X, Y)
            check(X + dx, Y + dy)


while time.time() - start < 1.2:
    scale = random.randint(1, 6)
    X = random.randint(-(10**scale), 10**scale) + dx
    Y = random.randint(-(10**scale), 10**scale) + dy
    check(X, Y)

print(*ans)
0