結果
問題 | No.94 圏外です。(EASY) |
ユーザー | ckawatak |
提出日時 | 2019-04-24 23:02:09 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 260 ms / 5,000 ms |
コード長 | 1,178 bytes |
コンパイル時間 | 305 ms |
コンパイル使用メモリ | 82,376 KB |
実行使用メモリ | 77,740 KB |
最終ジャッジ日時 | 2024-11-15 18:13:34 |
合計ジャッジ時間 | 3,531 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
55,748 KB |
testcase_01 | AC | 41 ms
55,276 KB |
testcase_02 | AC | 42 ms
55,012 KB |
testcase_03 | AC | 41 ms
54,688 KB |
testcase_04 | AC | 51 ms
62,964 KB |
testcase_05 | AC | 56 ms
66,508 KB |
testcase_06 | AC | 70 ms
73,100 KB |
testcase_07 | AC | 77 ms
74,808 KB |
testcase_08 | AC | 96 ms
77,288 KB |
testcase_09 | AC | 130 ms
77,328 KB |
testcase_10 | AC | 150 ms
77,672 KB |
testcase_11 | AC | 119 ms
77,216 KB |
testcase_12 | AC | 136 ms
76,968 KB |
testcase_13 | AC | 131 ms
77,148 KB |
testcase_14 | AC | 165 ms
77,316 KB |
testcase_15 | AC | 146 ms
77,408 KB |
testcase_16 | AC | 178 ms
77,644 KB |
testcase_17 | AC | 150 ms
77,720 KB |
testcase_18 | AC | 156 ms
77,176 KB |
testcase_19 | AC | 260 ms
77,740 KB |
testcase_20 | AC | 43 ms
54,808 KB |
testcase_21 | AC | 41 ms
54,948 KB |
ソースコード
from math import sqrt from collections import deque N = int(input()) points = [] for _ in range(N): points.append(list(map(int, input().split()))) G = [] for i in range(N): graph = [] for j in range(N): distance = (points[i][0]-points[j][0])**2 + \ (points[i][1]-points[j][1])**2 if distance <= 100: graph.append(j) G.append(graph) def dfs(start): reached = [] visited = [False for _ in range(N)] que = deque() que.append(start) while len(que) != 0: adjacent = que.popleft() visited[adjacent] = True reached.extend(G[adjacent]) for point in G[adjacent]: if not visited[point]: que.appendleft(point) longest = 0 for end in reached: distance = sqrt((points[start][0]-points[end][0])**2 + \ (points[start][1]-points[end][1])**2) longest = max(longest, distance) return longest longest = 0 for i in range(N): longest = max(longest, dfs(i)) if longest == 0: if len(points) == 0: print(1) else: print(2) else: print(longest+2)