結果
問題 | No.168 ものさし |
ユーザー | roaris |
提出日時 | 2019-10-30 15:40:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,161 ms / 2,000 ms |
コード長 | 1,515 bytes |
コンパイル時間 | 767 ms |
コンパイル使用メモリ | 86,840 KB |
実行使用メモリ | 162,052 KB |
最終ジャッジ日時 | 2023-10-12 23:49:24 |
合計ジャッジ時間 | 14,565 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 422 ms
112,340 KB |
testcase_01 | AC | 216 ms
88,744 KB |
testcase_02 | AC | 218 ms
88,536 KB |
testcase_03 | AC | 214 ms
88,424 KB |
testcase_04 | AC | 211 ms
88,468 KB |
testcase_05 | AC | 218 ms
88,536 KB |
testcase_06 | AC | 212 ms
88,604 KB |
testcase_07 | AC | 210 ms
88,576 KB |
testcase_08 | AC | 209 ms
88,620 KB |
testcase_09 | AC | 223 ms
91,908 KB |
testcase_10 | AC | 237 ms
92,100 KB |
testcase_11 | AC | 361 ms
98,888 KB |
testcase_12 | AC | 859 ms
149,916 KB |
testcase_13 | AC | 1,156 ms
161,064 KB |
testcase_14 | AC | 1,116 ms
162,052 KB |
testcase_15 | AC | 212 ms
88,672 KB |
testcase_16 | AC | 221 ms
91,856 KB |
testcase_17 | AC | 226 ms
91,892 KB |
testcase_18 | AC | 247 ms
92,524 KB |
testcase_19 | AC | 1,094 ms
160,064 KB |
testcase_20 | AC | 1,161 ms
161,508 KB |
testcase_21 | AC | 1,158 ms
162,040 KB |
testcase_22 | AC | 1,145 ms
161,876 KB |
ソースコード
import sys input = sys.stdin.readline from decimal import * class Unionfind(): def __init__(self, n): self.par = [-1] * n self.rank = [1] * n def root(self, x): if self.par[x] < 0: return x self.par[x] = self.root(self.par[x]) return self.par[x] def unite(self, x, y): rx, ry = self.root(x), self.root(y) if rx != ry: if self.rank[rx] >= self.rank[ry]: self.par[rx] += self.par[ry] self.par[ry] = rx if self.rank[rx] == self.rank[ry]: self.rank[rx] += 1 else: self.par[ry] += self.par[rx] self.par[rx] = ry def is_same(self, x, y): return self.root(x) == self.root(y) def count(self, x): return -self.par[x] N = int(input()) XY = [tuple(map(int, input().split())) for _ in range(N)] edges = [] for i in range(N): for j in range(i+1, N): Xi, Yi = XY[i] Xj, Yj = XY[j] edges.append((i, j, (Xi-Xj)**2+(Yi-Yj)**2)) edges.sort(key=lambda k: k[2]) uf = Unionfind(N) for s, t, w in edges: uf.unite(s, t) if uf.is_same(0, N-1): ng, ok = -1, 10**11 while abs(ok-ng) > 1: mid = (ng+ok)//2 if (mid*10)**2 >= w: ok = mid else: ng = mid print(10*ok) break