結果

問題 No.94 圏外です。(EASY)
ユーザー titiatitia
提出日時 2022-04-19 05:26:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 705 ms / 5,000 ms
コード長 967 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 11,092 KB
実行使用メモリ 8,772 KB
最終ジャッジ日時 2023-08-29 23:44:45
合計ジャッジ時間 7,068 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,436 KB
testcase_01 AC 16 ms
8,224 KB
testcase_02 AC 16 ms
8,388 KB
testcase_03 AC 16 ms
7,964 KB
testcase_04 AC 23 ms
8,548 KB
testcase_05 AC 34 ms
8,448 KB
testcase_06 AC 61 ms
8,592 KB
testcase_07 AC 115 ms
8,552 KB
testcase_08 AC 228 ms
8,532 KB
testcase_09 AC 428 ms
8,772 KB
testcase_10 AC 439 ms
8,576 KB
testcase_11 AC 413 ms
8,628 KB
testcase_12 AC 438 ms
8,616 KB
testcase_13 AC 429 ms
8,628 KB
testcase_14 AC 431 ms
8,204 KB
testcase_15 AC 438 ms
8,704 KB
testcase_16 AC 453 ms
8,672 KB
testcase_17 AC 435 ms
8,580 KB
testcase_18 AC 441 ms
8,604 KB
testcase_19 AC 705 ms
8,684 KB
testcase_20 AC 17 ms
8,528 KB
testcase_21 AC 17 ms
8,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())

XY=[tuple(map(int,input().split())) for i in range(N)]

# UnionFind

Group = [i for i in range(N+1)] # グループ分け
Nodes = [1]*(N+1) # 各グループのノードの数

def find(x):
    while Group[x] != x:
        x=Group[x]
    return x

def Union(x,y):
    if find(x) != find(y):
        if Nodes[find(x)] < Nodes[find(y)]:
            
            Nodes[find(y)] += Nodes[find(x)]
            Nodes[find(x)] = 0
            Group[find(x)] = find(y)
            
        else:
            Nodes[find(x)] += Nodes[find(y)]
            Nodes[find(y)] = 0
            Group[find(y)] = find(x)

for i in range(N):
    x,y=XY[i]
    for j in range(i+1,N):
        z,w=XY[j]

        if (x-z)**2+(y-w)**2<=100:
            Union(i,j)

MAX=0

for i in range(N):
    x,y=XY[i]
    for j in range(i+1,N):
        z,w=XY[j]

        if find(i)==find(j):
            MAX=max(MAX,(x-z)**2+(y-w)**2)

if N!=0:
    print(MAX**(1/2)+2)
else:
    print(1)
0