結果
問題 | No.96 圏外です。 |
ユーザー | しらっ亭 |
提出日時 | 2015-08-31 00:32:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,033 ms / 5,000 ms |
コード長 | 2,391 bytes |
コンパイル時間 | 345 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 296,520 KB |
最終ジャッジ日時 | 2024-12-24 08:23:23 |
合計ジャッジ時間 | 14,706 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
54,912 KB |
testcase_01 | AC | 51 ms
54,656 KB |
testcase_02 | AC | 51 ms
54,656 KB |
testcase_03 | AC | 54 ms
54,400 KB |
testcase_04 | AC | 117 ms
81,920 KB |
testcase_05 | AC | 131 ms
83,200 KB |
testcase_06 | AC | 151 ms
90,992 KB |
testcase_07 | AC | 186 ms
94,404 KB |
testcase_08 | AC | 186 ms
108,128 KB |
testcase_09 | AC | 218 ms
108,124 KB |
testcase_10 | AC | 332 ms
100,408 KB |
testcase_11 | AC | 340 ms
123,212 KB |
testcase_12 | AC | 370 ms
145,928 KB |
testcase_13 | AC | 576 ms
115,688 KB |
testcase_14 | AC | 589 ms
155,824 KB |
testcase_15 | AC | 800 ms
127,152 KB |
testcase_16 | AC | 816 ms
189,176 KB |
testcase_17 | AC | 954 ms
296,520 KB |
testcase_18 | AC | 982 ms
208,024 KB |
testcase_19 | AC | 1,014 ms
208,360 KB |
testcase_20 | AC | 671 ms
119,900 KB |
testcase_21 | AC | 1,033 ms
149,948 KB |
testcase_22 | AC | 494 ms
101,216 KB |
testcase_23 | AC | 555 ms
101,780 KB |
testcase_24 | AC | 43 ms
54,272 KB |
testcase_25 | AC | 616 ms
194,728 KB |
testcase_26 | AC | 796 ms
256,612 KB |
testcase_27 | AC | 709 ms
227,208 KB |
ソースコード
from collections import defaultdictfrom itertools import combinationsimport mathclass UnionFind:def __init__(self, n):self.par = list(range(n))def find(self, x):if self.par[x] == x:return xelse:self.par[x] = self.find(self.par[x])return self.par[x]def union(self, x, y):x = self.find(x)y = self.find(y)if x == y:returnself.par[x] = ydef convex_hull(P):def veccross(A, B, C):return (C[0] - A[0]) * (B[1] - A[1]) - (C[1] - A[1]) * (B[0] - A[0])n = len(P)if n <= 2:return list(range(n))ps = [None] * nfor i in range(n):ps[i] = (P[i], i)ps.sort()k = 0res = [0] * (n * 2)for i in range(n):while k > 1 and veccross(P[res[k - 2]], P[res[k - 1]], ps[i][0]) <= 0:k -= 1res[k] = ps[i][1]k += 1t = kfor i in range(n - 2, -1, -1):while k > t and veccross(P[res[k - 2]], P[res[k - 1]], ps[i][0]) <= 0:k -= 1res[k] = ps[i][1]k += 1return res[:k - 1]def m_dist(g, xs, ys):ps = [(xs[i], ys[i]) for i in g]os = convex_hull(ps)ma = 0for i, j in combinations(os, 2):ma = max(ma, (ps[i][0] - ps[j][0]) ** 2 + (ps[i][1] - ps[j][1]) ** 2)return madef solve():N = int(input())XS = [0] * NYS = [0] * NB = defaultdict(list)def b(x, y):if 0 <= x <= 2000 and 0 <= y <= 2000:return B[x, y]else:return []ds = [(-1, -1), (0, -1), (1, -1), (-1, 0), (0, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]uf = UnionFind(N)for i in range(N):x, y = map(int, input().split())x += 10000y += 10000XS[i] = xYS[i] = yx10 = x // 10y10 = y // 10for dx, dy in ds:for j in b(x10 + dx, y10 + dy):if (x - XS[j]) ** 2 + (y - YS[j]) ** 2 <= 100:uf.union(i, j)B[x10, y10].append(i)gd = defaultdict(list)for i in range(N):gd[uf.find(i)].append(i)if len(gd) == 0:print(1)else:ma = 0for g in gd.values():ma = max(ma, m_dist(g, XS, YS))print(math.sqrt(ma) + 2)if __name__ == '__main__':solve()