結果
問題 | No.168 ものさし |
ユーザー | tnodino |
提出日時 | 2022-07-24 13:17:15 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 371 ms / 2,000 ms |
コード長 | 1,094 bytes |
コンパイル時間 | 393 ms |
コンパイル使用メモリ | 86,996 KB |
実行使用メモリ | 80,668 KB |
最終ジャッジ日時 | 2023-09-20 12:14:40 |
合計ジャッジ時間 | 6,266 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 231 ms
79,104 KB |
testcase_01 | AC | 95 ms
71,548 KB |
testcase_02 | AC | 96 ms
71,728 KB |
testcase_03 | AC | 97 ms
71,380 KB |
testcase_04 | AC | 97 ms
71,376 KB |
testcase_05 | AC | 94 ms
71,572 KB |
testcase_06 | AC | 107 ms
76,940 KB |
testcase_07 | AC | 97 ms
71,492 KB |
testcase_08 | AC | 98 ms
71,432 KB |
testcase_09 | AC | 144 ms
78,176 KB |
testcase_10 | AC | 161 ms
78,016 KB |
testcase_11 | AC | 220 ms
78,584 KB |
testcase_12 | AC | 324 ms
79,200 KB |
testcase_13 | AC | 371 ms
79,924 KB |
testcase_14 | AC | 347 ms
78,836 KB |
testcase_15 | AC | 98 ms
71,196 KB |
testcase_16 | AC | 143 ms
78,816 KB |
testcase_17 | AC | 157 ms
78,068 KB |
testcase_18 | AC | 178 ms
78,000 KB |
testcase_19 | AC | 340 ms
79,736 KB |
testcase_20 | AC | 339 ms
79,480 KB |
testcase_21 | AC | 358 ms
80,668 KB |
testcase_22 | AC | 358 ms
79,888 KB |
ソースコード
from collections import deque class UnionFind: def __init__(self, sz): self.par = [-1] * sz def root(self, pos): if self.par[pos] < 0: return pos self.par[pos] = self.root(self.par[pos]) return self.par[pos] def unite(self, u, v): u = self.root(u) v = self.root(v) if u == v: return self.par[u] += self.par[v] self.par[v] = u def same(self, u, v): if self.root(u) == self.root(v): return True return False def size(self, pos): return -self.par[self.root(pos)] def check(x): UF = UnionFind(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: UF.unite(i, j) return UF.same(0, N-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)