結果

問題 No.94 圏外です。(EASY)
ユーザー ckawatakckawatak
提出日時 2019-04-23 23:10:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,161 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 82,512 KB
実行使用メモリ 86,728 KB
最終ジャッジ日時 2024-04-24 01:35:15
合計ジャッジ時間 38,500 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
55,976 KB
testcase_01 AC 40 ms
54,984 KB
testcase_02 AC 37 ms
54,940 KB
testcase_03 AC 37 ms
54,964 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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(i+1,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, end):
    distance = 0    
    visited = [False for _ in range(N)]

    que = deque()
    que.append(start)
    while len(que) != 0:
        adjacent = que.popleft()
        if adjacent == end:
            distance = sqrt((points[start][0]-points[adjacent][0])**2 + \
                (points[start][1]-points[adjacent][1])**2)
            break
        visited[adjacent] = True
        for point in G[adjacent]:
            if not visited[point]:
                que.appendleft(point)
    return distance

longest = 0
for i in range(N-1):
    for j in range(1,N):
        distance = dfs(i,j)
        longest = max(longest, distance)

if longest == 0:
    if len(points) == 0:
        print(1)
    else:
        print(2)
else:
    print(longest+2)
0