結果

問題 No.94 圏外です。(EASY)
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-07-23 01:56:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 5,000 ms
コード長 1,811 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 81,660 KB
実行使用メモリ 76,716 KB
最終ジャッジ日時 2023-10-24 08:28:29
合計ジャッジ時間 3,004 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
55,760 KB
testcase_01 AC 48 ms
55,688 KB
testcase_02 AC 48 ms
55,760 KB
testcase_03 AC 48 ms
55,688 KB
testcase_04 AC 55 ms
63,988 KB
testcase_05 AC 56 ms
64,164 KB
testcase_06 AC 60 ms
66,352 KB
testcase_07 AC 66 ms
68,580 KB
testcase_08 AC 75 ms
70,876 KB
testcase_09 AC 81 ms
73,200 KB
testcase_10 AC 82 ms
73,364 KB
testcase_11 AC 84 ms
73,712 KB
testcase_12 AC 82 ms
73,240 KB
testcase_13 AC 81 ms
73,156 KB
testcase_14 AC 83 ms
73,884 KB
testcase_15 AC 87 ms
74,544 KB
testcase_16 AC 92 ms
76,716 KB
testcase_17 AC 99 ms
76,708 KB
testcase_18 AC 95 ms
76,692 KB
testcase_19 AC 95 ms
76,640 KB
testcase_20 AC 50 ms
57,808 KB
testcase_21 AC 49 ms
55,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

class DSU:
    def __init__(self, n):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a, b):
        assert 0 <= a < self._n
        assert 0 <= b < self._n
        x, y = self.leader(a), self.leader(b)
        if x == y: return x
        if -self.parent_or_size[x] < -self.parent_or_size[y]: x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def same(self, a, b):
        assert 0 <= a < self._n
        assert 0 <= b < self._n
        return self.leader(a) == self.leader(b)

    def leader(self, a):
        assert 0 <= a < self._n
        if self.parent_or_size[a] < 0: return a
        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a):
        assert 0 <= a < self._n
        return -self.parent_or_size[self.leader(a)]

    def groups(self):
        leader_buf = [self.leader(i) for i in range(self._n)]
        result = [[] for _ in range(self._n)]
        for i in range(self._n): result[leader_buf[i]].append(i)
        return [r for r in result if r != []]

N = int(input())
X = [tuple(map(int,input().split())) for _ in range(N)]
D = DSU(N)
for i in range(N-1):
    xi,yi = X[i]
    for j in range(i+1,N):
        xj,yj = X[j]
        if (xi-xj)**2 + (yi-yj)**2 <= 100:
            D.merge(i,j)
ans = 2
if N==0:
    print(1)
    exit()
for g in D.groups():
    
    n = len(g)
    for i in range(n-1):
        xi,yi = X[g[i]]
        for j in range(i+1,n):
            xj,yj = X[g[j]]
            tmp = math.sqrt((xi-xj)**2 + (yi-yj)**2)
            ans = max(ans,tmp+2)
print(ans)
0