結果
問題 | No.2632 Center of Three Points in Lp Norm |
ユーザー | tassei903 |
提出日時 | 2024-02-13 06:08:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 211 ms / 2,000 ms |
コード長 | 2,121 bytes |
コンパイル時間 | 381 ms |
コンパイル使用メモリ | 82,160 KB |
実行使用メモリ | 78,360 KB |
最終ジャッジ日時 | 2024-09-28 18:16:37 |
合計ジャッジ時間 | 10,025 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 186 ms
77,872 KB |
testcase_01 | AC | 151 ms
77,192 KB |
testcase_02 | AC | 169 ms
77,104 KB |
testcase_03 | AC | 178 ms
78,256 KB |
testcase_04 | AC | 178 ms
77,788 KB |
testcase_05 | AC | 180 ms
77,468 KB |
testcase_06 | AC | 165 ms
77,652 KB |
testcase_07 | AC | 187 ms
78,284 KB |
testcase_08 | AC | 154 ms
77,204 KB |
testcase_09 | AC | 180 ms
78,064 KB |
testcase_10 | AC | 181 ms
77,908 KB |
testcase_11 | AC | 168 ms
77,852 KB |
testcase_12 | AC | 200 ms
78,016 KB |
testcase_13 | AC | 170 ms
77,864 KB |
testcase_14 | AC | 205 ms
78,268 KB |
testcase_15 | AC | 172 ms
78,360 KB |
testcase_16 | AC | 183 ms
78,056 KB |
testcase_17 | AC | 200 ms
78,040 KB |
testcase_18 | AC | 191 ms
78,140 KB |
testcase_19 | AC | 180 ms
78,152 KB |
testcase_20 | AC | 185 ms
77,796 KB |
testcase_21 | AC | 191 ms
78,332 KB |
testcase_22 | AC | 176 ms
77,872 KB |
testcase_23 | AC | 192 ms
78,284 KB |
testcase_24 | AC | 175 ms
77,704 KB |
testcase_25 | AC | 192 ms
78,008 KB |
testcase_26 | AC | 192 ms
78,200 KB |
testcase_27 | AC | 195 ms
78,180 KB |
testcase_28 | AC | 174 ms
77,352 KB |
testcase_29 | AC | 171 ms
78,256 KB |
testcase_30 | AC | 178 ms
77,748 KB |
testcase_31 | AC | 158 ms
77,268 KB |
testcase_32 | AC | 157 ms
77,120 KB |
testcase_33 | AC | 118 ms
76,216 KB |
testcase_34 | AC | 211 ms
78,224 KB |
testcase_35 | AC | 138 ms
76,840 KB |
testcase_36 | AC | 187 ms
77,996 KB |
testcase_37 | AC | 153 ms
77,220 KB |
ソースコード
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]) if x > y: x, y = y, x if y == 0.0: return 0.0 x /= y if pow(x, p + 2) < 1e-18: return (1.0 + pow(x, p) / p) * y return pow(1.0 + pow(x, p), 1 / p) * y 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(200): 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) #print(x, uy) if dist(c, (x, uy)) < dist(left, (x, uy)): up = c down = left else: up = left down = c #print(up, down, left, right) #print(dist(up, (x, uy)), dist(down, (x, uy)), dist(up, (f(left, right, uy), uy)), dist(down, (f(left, right, uy), uy))) for _ in range(200): 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)