結果
問題 |
No.168 ものさし
|
ユーザー |
![]() |
提出日時 | 2022-07-24 13:12:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 549 ms / 2,000 ms |
コード長 | 801 bytes |
コンパイル時間 | 152 ms |
コンパイル使用メモリ | 82,320 KB |
実行使用メモリ | 271,852 KB |
最終ジャッジ日時 | 2024-07-06 07:25:26 |
合計ジャッジ時間 | 4,525 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
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)