結果

問題 No.94 圏外です。(EASY)
ユーザー tktk_snsntktk_snsn
提出日時 2021-03-02 21:53:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 894 ms / 5,000 ms
コード長 894 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-14 04:59:37
合計ジャッジ時間 8,262 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 33 ms
10,752 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 36 ms
10,752 KB
testcase_05 AC 49 ms
11,008 KB
testcase_06 AC 82 ms
10,880 KB
testcase_07 AC 155 ms
10,880 KB
testcase_08 AC 288 ms
10,880 KB
testcase_09 AC 533 ms
10,880 KB
testcase_10 AC 534 ms
10,880 KB
testcase_11 AC 518 ms
10,880 KB
testcase_12 AC 541 ms
11,008 KB
testcase_13 AC 537 ms
11,008 KB
testcase_14 AC 545 ms
10,880 KB
testcase_15 AC 543 ms
11,008 KB
testcase_16 AC 553 ms
10,880 KB
testcase_17 AC 545 ms
10,880 KB
testcase_18 AC 550 ms
10,880 KB
testcase_19 AC 894 ms
11,136 KB
testcase_20 AC 30 ms
11,008 KB
testcase_21 AC 30 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
XY = tuple(tuple(map(int, input().split())) for _ in range(N))
if N == 0:
    print(1)
    exit()

root = [-1] * N

def find(i):
    if root[i] < 0:
        return i
    root[i] = find(root[i])
    return root[i]

def same(x, y):
    return find(x) == find(y)

def merge(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if -root[x] > -root[y]:
        x, y = y, x
    root[x] += root[y]
    root[y] = x


for i, (xi, yi) in enumerate(XY):
    for j, (xj, yj) in enumerate(XY[i + 1:], i + 1):
        if (xi - xj)** 2 + (yi - yj)** 2 <= 100:
            merge(i, j)

ans = 0
for i, (xi, yi) in enumerate(XY):
    for j, (xj, yj) in enumerate(XY[i + 1:], i + 1):
        if same(i, j):
            d = (xi-xj)**2+(yi-yj)**2
            ans = max(ans, d)

print(2.0 + ans ** 0.5)
0