結果

問題 No.168 ものさし
ユーザー tnodino
提出日時 2022-07-24 13:11:58
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 801 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 34,552 KB
最終ジャッジ日時 2024-07-06 07:25:00
合計ジャッジ時間 8,301 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 8 TLE * 1 -- * 10
権限があれば一括ダウンロードができます

ソースコード

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