結果

問題 No.168 ものさし
ユーザー maspymaspy
提出日時 2020-03-07 06:02:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 732 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 156,164 KB
最終ジャッジ日時 2024-04-22 11:53:44
合計ジャッジ時間 34,998 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 991 ms
54,232 KB
testcase_02 AC 981 ms
54,484 KB
testcase_03 AC 987 ms
54,484 KB
testcase_04 AC 990 ms
54,228 KB
testcase_05 AC 996 ms
54,740 KB
testcase_06 AC 984 ms
54,228 KB
testcase_07 AC 989 ms
54,480 KB
testcase_08 AC 984 ms
54,484 KB
testcase_09 AC 1,000 ms
54,488 KB
testcase_10 AC 1,022 ms
54,996 KB
testcase_11 AC 1,229 ms
64,460 KB
testcase_12 AC 1,833 ms
91,916 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 991 ms
54,364 KB
testcase_16 AC 994 ms
54,572 KB
testcase_17 AC 996 ms
54,488 KB
testcase_18 AC 1,016 ms
55,900 KB
testcase_19 AC 1,665 ms
106,076 KB
testcase_20 AC 1,701 ms
107,884 KB
testcase_21 AC 1,696 ms
107,916 KB
testcase_22 AC 1,701 ms
156,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from scipy.sparse.csgraph import connected_components

# %%
N = int(readline())
XY = np.array(read().split(), np.int64)
X = XY[::2]
Y = XY[1::2]

# %%
dx = X[:, None] - X[None, :]
dy = Y[:, None] - Y[None, :]
dist_mat = dx**2 + dy**2

# %%


def test(x):
    graph = dist_mat <= x * x
    _, comp = connected_components(graph, directed=False)
    return comp[0] == comp[-1]


# %%
left = 0
right = 10 ** 9 * 2
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        right = x
    else:
        left = x

answer = right + (-right) % 10
print(answer)
0