結果
問題 |
No.94 圏外です。(EASY)
|
ユーザー |
![]() |
提出日時 | 2025-03-31 17:34:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 68 ms / 5,000 ms |
コード長 | 1,885 bytes |
コンパイル時間 | 487 ms |
コンパイル使用メモリ | 82,988 KB |
実行使用メモリ | 69,988 KB |
最終ジャッジ日時 | 2025-03-31 17:34:51 |
合計ジャッジ時間 | 2,387 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
import sys import math class UnionFind: def __init__(self, size): self.parent = list(range(size)) def find(self, x): if self.parent[x] != x: self.parent[x] = self.find(self.parent[x]) return self.parent[x] def unite(self, x, y): x_root = self.find(x) y_root = self.find(y) if x_root == y_root: return self.parent[y_root] = x_root def main(): input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 if N == 0: print(1.0) return points = [] for _ in range(N): x = int(input[ptr]) y = int(input[ptr+1]) points.append((x, y)) ptr += 2 uf = UnionFind(N) for i in range(N): xi, yi = points[i] for j in range(i + 1, N): xj, yj = points[j] dx = xj - xi dy = yj - yi dist_sq = dx * dx + dy * dy if dist_sq <= 100: # 10^2 uf.unite(i, j) groups = {} for i in range(N): root = uf.find(i) if root not in groups: groups[root] = [] groups[root].append(points[i]) max_candidate = 0.0 for g in groups.values(): current_max = 0.0 m = len(g) for i in range(m): x1, y1 = g[i] for j in range(i + 1, m): x2, y2 = g[j] dx = x2 - x1 dy = y2 - y1 dist_sq = dx * dx + dy * dy if dist_sq > current_max: current_max = dist_sq current_d = math.sqrt(current_max) if current_max != 0.0 else 0.0 candidate = current_d + 2.0 if candidate > max_candidate: max_candidate = candidate print("{0:.9f}".format(max_candidate)) if __name__ == "__main__": main()