結果

問題 No.168 ものさし
ユーザー 山本信二山本信二
提出日時 2022-04-17 09:37:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,201 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 81,832 KB
最終ジャッジ日時 2023-08-27 00:43:36
合計ジャッジ時間 14,090 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 348 ms
51,336 KB
testcase_01 AC 211 ms
42,932 KB
testcase_02 AC 207 ms
42,832 KB
testcase_03 AC 206 ms
42,820 KB
testcase_04 AC 210 ms
42,728 KB
testcase_05 AC 211 ms
42,920 KB
testcase_06 AC 207 ms
42,784 KB
testcase_07 AC 212 ms
42,684 KB
testcase_08 AC 206 ms
43,024 KB
testcase_09 AC 212 ms
43,228 KB
testcase_10 AC 234 ms
44,096 KB
testcase_11 AC 388 ms
50,816 KB
testcase_12 AC 864 ms
70,204 KB
testcase_13 AC 1,197 ms
81,832 KB
testcase_14 AC 1,201 ms
81,764 KB
testcase_15 AC 205 ms
43,052 KB
testcase_16 AC 217 ms
43,160 KB
testcase_17 AC 219 ms
43,624 KB
testcase_18 AC 234 ms
44,860 KB
testcase_19 AC 682 ms
79,680 KB
testcase_20 AC 719 ms
80,972 KB
testcase_21 AC 718 ms
81,204 KB
testcase_22 AC 725 ms
81,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
from scipy.sparse.csgraph import connected_components

N = int(input())
P = np.array([tuple(map(int, input().split())) for _ in range(N)],dtype=np.int64)
X, Y = P[:, 0], P[:, 1]
D = (X[:, None] - X[None, :]) ** 2 + (Y[:, None] - Y[None, :]) ** 2


def f(x):
    _, labels = connected_components(D <= x ** 2)
    return labels[0] == labels[-1]


# bisect
l, r = 0, 2 * 10 ** 9
while r - l > 10:
    m = (r + l) // 20 * 10
    if f(m):
        r = m
    else:
        l = m
print(r)
0