結果

問題 No.168 ものさし
ユーザー tnodinotnodino
提出日時 2022-07-24 13:11:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 801 bytes
コンパイル時間 68 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 29,896 KB
最終ジャッジ日時 2023-09-20 12:06:48
合計ジャッジ時間 7,222 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 995 ms
13,948 KB
testcase_01 AC 19 ms
8,668 KB
testcase_02 AC 19 ms
8,648 KB
testcase_03 AC 19 ms
8,664 KB
testcase_04 AC 19 ms
8,700 KB
testcase_05 AC 19 ms
8,620 KB
testcase_06 AC 20 ms
8,600 KB
testcase_07 AC 19 ms
8,588 KB
testcase_08 AC 20 ms
8,668 KB
testcase_09 AC 51 ms
8,680 KB
testcase_10 AC 144 ms
9,136 KB
testcase_11 AC 1,053 ms
13,056 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
def check(x):
    G = [[] for _ in range(N)]
    for i in range(N):
        for j in range(i+1,N):
            d = (X[i]-X[j])**2 + (Y[i]-Y[j])**2
            if d <= x:
                G[i].append(j)
                G[j].append(i)
    flg = [False] * N
    flg[0] = True
    Queue = deque()
    Queue.append(0)
    while Queue:
        pos = Queue.popleft()
        for nxt in G[pos]:
            if flg[nxt]:
                continue
            flg[nxt] = True
            Queue.append(nxt)
    return flg[-1]

N = int(input())
Z = [list(map(int,input().split())) for _ in range(N)]
X,Y = [list(i) for i in zip(*Z)]
ng = 0
ok = 1<<32
while ok - ng > 1:
    x = (ok+ng) // 2
    if check(x**2):
        ok = x
    else:
        ng = x
ok = (ok + 9) // 10 * 10
print(ok)
0