結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー hedwig100hedwig100
提出日時 2020-05-29 21:52:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,164 ms / 2,000 ms
コード長 982 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 82,276 KB
実行使用メモリ 142,872 KB
最終ジャッジ日時 2024-04-23 21:49:01
合計ジャッジ時間 25,033 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,816 KB
testcase_01 AC 40 ms
53,632 KB
testcase_02 AC 631 ms
110,728 KB
testcase_03 AC 765 ms
141,504 KB
testcase_04 AC 749 ms
140,692 KB
testcase_05 AC 550 ms
137,076 KB
testcase_06 AC 537 ms
136,912 KB
testcase_07 AC 209 ms
94,132 KB
testcase_08 AC 504 ms
142,872 KB
testcase_09 AC 137 ms
82,904 KB
testcase_10 AC 278 ms
105,712 KB
testcase_11 AC 215 ms
96,748 KB
testcase_12 AC 170 ms
87,052 KB
testcase_13 AC 872 ms
120,652 KB
testcase_14 AC 844 ms
125,240 KB
testcase_15 AC 917 ms
134,552 KB
testcase_16 AC 476 ms
104,340 KB
testcase_17 AC 988 ms
139,744 KB
testcase_18 AC 394 ms
96,716 KB
testcase_19 AC 926 ms
136,924 KB
testcase_20 AC 315 ms
92,936 KB
testcase_21 AC 427 ms
101,144 KB
testcase_22 AC 866 ms
130,512 KB
testcase_23 AC 74 ms
74,376 KB
testcase_24 AC 84 ms
77,644 KB
testcase_25 AC 164 ms
86,788 KB
testcase_26 AC 516 ms
108,924 KB
testcase_27 AC 572 ms
108,984 KB
testcase_28 AC 907 ms
131,480 KB
testcase_29 AC 211 ms
84,148 KB
testcase_30 AC 926 ms
134,180 KB
testcase_31 AC 652 ms
119,096 KB
testcase_32 AC 475 ms
104,364 KB
testcase_33 AC 1,164 ms
136,204 KB
testcase_34 AC 419 ms
97,664 KB
testcase_35 AC 931 ms
136,164 KB
testcase_36 AC 88 ms
76,988 KB
testcase_37 AC 133 ms
78,568 KB
testcase_38 AC 97 ms
77,320 KB
testcase_39 AC 134 ms
78,508 KB
testcase_40 AC 62 ms
65,984 KB
testcase_41 AC 1,106 ms
142,580 KB
testcase_42 AC 387 ms
97,936 KB
testcase_43 AC 606 ms
112,292 KB
testcase_44 AC 296 ms
90,836 KB
testcase_45 AC 574 ms
111,512 KB
testcase_46 AC 40 ms
52,860 KB
testcase_47 AC 40 ms
54,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
from heapq import heapify,heappop,heappush

def dijkstra(G,s = 0): #sを始点とした最短経を求める
    n = len(G)
    dist = [INF] * n
    dist[s] = 0
    q = [(0,s)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for e,cost in G[v]:
            if dist[e] > dist[v] + cost:
                dist[e] = dist[v] + cost
                heappush(q,(dist[e],e))
    return dist
N,M = map(int,input().split())
X,Y = map(int,input().split())
point = [list(map(int,input().split())) for _ in range(N)]
dist = lambda i,j:((point[i][0] - point[j][0])*(point[i][0] - point[j][0]) + (point[i][1] - point[j][1])*(point[i][1] - point[j][1]))**0.5
G = [[] for _ in range(N)]
for _ in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    d = dist(x,y)
    G[x].append((y,d))
    G[y].append((x,d))
dist = dijkstra(G,X - 1)
ans = dist[Y - 1]
print(ans)
0