結果

問題 No.168 ものさし
ユーザー H3PO4H3PO4
提出日時 2020-08-11 21:39:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,694 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 93,212 KB
最終ジャッジ日時 2024-04-17 17:39:05
合計ジャッジ時間 28,661 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,166 ms
62,612 KB
testcase_01 AC 777 ms
54,868 KB
testcase_02 AC 776 ms
54,240 KB
testcase_03 AC 781 ms
54,476 KB
testcase_04 AC 778 ms
54,492 KB
testcase_05 AC 778 ms
54,616 KB
testcase_06 AC 780 ms
54,616 KB
testcase_07 AC 779 ms
54,744 KB
testcase_08 AC 784 ms
54,624 KB
testcase_09 AC 791 ms
54,240 KB
testcase_10 AC 805 ms
54,624 KB
testcase_11 AC 971 ms
61,248 KB
testcase_12 AC 1,459 ms
81,172 KB
testcase_13 AC 1,679 ms
93,212 KB
testcase_14 AC 1,694 ms
92,740 KB
testcase_15 AC 774 ms
54,744 KB
testcase_16 AC 778 ms
54,748 KB
testcase_17 AC 787 ms
54,616 KB
testcase_18 AC 820 ms
55,128 KB
testcase_19 AC 1,258 ms
90,664 KB
testcase_20 AC 1,299 ms
92,204 KB
testcase_21 AC 1,311 ms
92,524 KB
testcase_22 AC 1,342 ms
92,632 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