結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー kohei2019kohei2019
提出日時 2022-07-18 00:25:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 935 ms / 2,000 ms
コード長 787 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 138,128 KB
最終ジャッジ日時 2023-09-12 12:38:19
合計ジャッジ時間 27,675 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,804 KB
testcase_01 AC 75 ms
71,636 KB
testcase_02 AC 537 ms
106,768 KB
testcase_03 AC 749 ms
138,128 KB
testcase_04 AC 704 ms
137,816 KB
testcase_05 AC 520 ms
134,624 KB
testcase_06 AC 584 ms
135,024 KB
testcase_07 AC 218 ms
92,260 KB
testcase_08 AC 449 ms
134,088 KB
testcase_09 AC 157 ms
80,576 KB
testcase_10 AC 273 ms
103,088 KB
testcase_11 AC 225 ms
93,476 KB
testcase_12 AC 211 ms
89,220 KB
testcase_13 AC 672 ms
118,224 KB
testcase_14 AC 745 ms
124,960 KB
testcase_15 AC 830 ms
133,140 KB
testcase_16 AC 501 ms
104,404 KB
testcase_17 AC 912 ms
137,808 KB
testcase_18 AC 412 ms
98,456 KB
testcase_19 AC 841 ms
134,132 KB
testcase_20 AC 339 ms
92,496 KB
testcase_21 AC 410 ms
101,720 KB
testcase_22 AC 793 ms
128,056 KB
testcase_23 AC 112 ms
78,452 KB
testcase_24 AC 116 ms
78,496 KB
testcase_25 AC 202 ms
89,428 KB
testcase_26 AC 502 ms
108,312 KB
testcase_27 AC 561 ms
107,704 KB
testcase_28 AC 822 ms
129,344 KB
testcase_29 AC 233 ms
85,276 KB
testcase_30 AC 882 ms
132,608 KB
testcase_31 AC 636 ms
117,480 KB
testcase_32 AC 466 ms
103,884 KB
testcase_33 AC 935 ms
134,332 KB
testcase_34 AC 429 ms
98,004 KB
testcase_35 AC 851 ms
134,424 KB
testcase_36 AC 124 ms
79,308 KB
testcase_37 AC 165 ms
79,356 KB
testcase_38 AC 131 ms
79,104 KB
testcase_39 AC 168 ms
79,404 KB
testcase_40 AC 99 ms
76,624 KB
testcase_41 AC 934 ms
135,228 KB
testcase_42 AC 476 ms
95,820 KB
testcase_43 AC 539 ms
107,712 KB
testcase_44 AC 285 ms
89,084 KB
testcase_45 AC 531 ms
106,708 KB
testcase_46 AC 77 ms
71,776 KB
testcase_47 AC 75 ms
71,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
N,M = map(int,input().split())
X,Y = map(int,input().split())
X,Y = X-1,Y-1
lsP = []
for i in range(N):
    p,q = map(int,input().split())
    lsP.append((p,q))
lsG = [[] for i in range(N)]
for i in range(M):
    P,Q = map(int,input().split())
    P -= 1
    Q -= 1
    dist = ((lsP[P][0]-lsP[Q][0])**2+(lsP[P][1]-lsP[Q][1])**2)**(1/2)
    lsG[P].append((Q,dist))
    lsG[Q].append((P,dist))

used = [False]*(N)
inf = float('INF')
lscost = [inf]*(N)
lscost[X] = 0
h = [(0,X)]
while h:
    c,n = heapq.heappop(h)
    if used[n]:
        continue
    used[n] = True
    for j,cost in lsG[n]:
        if used[j]:
            continue
        if lscost[j] > lscost[n] + cost:
            lscost[j] = lscost[n] + cost
            heapq.heappush(h, (lscost[j],j))
print(lscost[Y])
0