結果
| 問題 | No.2632 Center of Three Points in Lp Norm |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-16 23:11:49 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,095 bytes |
| 記録 | |
| コンパイル時間 | 1,014 ms |
| コンパイル使用メモリ | 20,676 KB |
| 実行使用メモリ | 152,700 KB |
| 最終ジャッジ日時 | 2026-04-15 10:05:52 |
| 合計ジャッジ時間 | 87,913 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 4 |
| other | TLE * 34 |
ソースコード
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())
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
for X in [-(10**6), 10**6]:
for Y in [-(10**6), 10**6]:
cur = scipy.optimize.fmin(f, [X, Y], disp=False, maxiter=1000, ftol=1e-8)
if f(cur) < best:
ans = cur
best = f(cur)
dx = (ax + bx + cx) / 3
dy = (ay + by + cy) / 3
while time.time() - start < 1.4:
scale = random.randint(1, 6)
X = random.randint(-(10**scale), 10**scale) + dx
Y = random.randint(-(10**scale), 10**scale) + dy
cur = scipy.optimize.fmin(f, [X, Y], disp=False, maxiter=1000, ftol=1e-8)
if f(cur) < best:
ans = cur
best = f(cur)
print(*ans)