結果

問題 No.168 ものさし
ユーザー maspymaspy
提出日時 2020-03-07 06:02:37
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,253 ms / 2,000 ms
コード長 732 bytes
コンパイル時間 435 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 97,452 KB
最終ジャッジ日時 2023-08-04 14:14:08
合計ジャッジ時間 13,001 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 338 ms
54,868 KB
testcase_01 AC 199 ms
43,060 KB
testcase_02 AC 200 ms
42,892 KB
testcase_03 AC 205 ms
42,936 KB
testcase_04 AC 200 ms
42,784 KB
testcase_05 AC 203 ms
42,808 KB
testcase_06 AC 203 ms
42,896 KB
testcase_07 AC 207 ms
42,700 KB
testcase_08 AC 208 ms
42,768 KB
testcase_09 AC 216 ms
43,272 KB
testcase_10 AC 231 ms
43,836 KB
testcase_11 AC 393 ms
54,036 KB
testcase_12 AC 865 ms
81,032 KB
testcase_13 AC 1,250 ms
97,040 KB
testcase_14 AC 1,253 ms
97,452 KB
testcase_15 AC 211 ms
42,744 KB
testcase_16 AC 212 ms
43,260 KB
testcase_17 AC 218 ms
43,672 KB
testcase_18 AC 231 ms
45,356 KB
testcase_19 AC 725 ms
94,484 KB
testcase_20 AC 750 ms
96,640 KB
testcase_21 AC 740 ms
96,876 KB
testcase_22 AC 740 ms
96,816 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