結果

問題 No.94 圏外です。(EASY)
ユーザー qibqib
提出日時 2023-02-18 21:19:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 162 ms / 5,000 ms
コード長 914 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 87,016 KB
最終ジャッジ日時 2023-09-27 10:45:25
合計ジャッジ時間 4,522 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,940 KB
testcase_01 AC 94 ms
72,092 KB
testcase_02 AC 92 ms
71,548 KB
testcase_03 AC 93 ms
71,572 KB
testcase_04 AC 110 ms
77,300 KB
testcase_05 AC 111 ms
77,960 KB
testcase_06 AC 122 ms
77,688 KB
testcase_07 AC 127 ms
77,872 KB
testcase_08 AC 127 ms
78,152 KB
testcase_09 AC 155 ms
86,460 KB
testcase_10 AC 151 ms
86,452 KB
testcase_11 AC 154 ms
86,648 KB
testcase_12 AC 162 ms
87,016 KB
testcase_13 AC 154 ms
86,320 KB
testcase_14 AC 154 ms
86,436 KB
testcase_15 AC 155 ms
86,724 KB
testcase_16 AC 156 ms
86,184 KB
testcase_17 AC 157 ms
86,500 KB
testcase_18 AC 143 ms
78,336 KB
testcase_19 AC 153 ms
86,456 KB
testcase_20 AC 100 ms
71,848 KB
testcase_21 AC 93 ms
71,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import math

n = int(input())

if n == 0:
  print("1.0")
  exit()

dist = [[1 << 60 for _ in range(n)] for _ in range(n)]

points = [list(map(int, input().split())) for _ in range(n)]
g = [[] for _ in range(n)]
for i in range(n - 1):
  xi, yi = points[i]
  for j in range(i + 1, n):
    xj, yj = points[j]
    d2 = (xj - xi) ** 2 + (yj - yi) ** 2
    dist[i][j] = d2
    if d2 <= 10 ** 2:
      g[i].append(j)
      g[j].append(i)

par = [None for _ in range(n)]
for src in range(n):
  if not par[src] is None:
    continue
  par[src] = src
  dq = deque()
  dq.append(src)
  while len(dq) > 0:
    cur = dq.popleft()
    for nxt in g[cur]:
      if not par[nxt] is None:
        continue
      par[nxt] = src
      dq.append(nxt)

ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    if par[i] == par[j]:
      ans = max(ans, dist[i][j])

ans = math.sqrt(ans) + 2
print(ans)
0