結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー titiatitia
提出日時 2020-05-29 21:48:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 851 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 145,908 KB
最終ジャッジ日時 2024-04-23 21:26:05
合計ジャッジ時間 20,258 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,480 KB
testcase_01 AC 45 ms
52,992 KB
testcase_02 AC 516 ms
111,624 KB
testcase_03 AC 687 ms
145,908 KB
testcase_04 AC 642 ms
145,520 KB
testcase_05 AC 461 ms
145,172 KB
testcase_06 AC 441 ms
144,788 KB
testcase_07 AC 132 ms
90,984 KB
testcase_08 AC 365 ms
140,844 KB
testcase_09 AC 96 ms
82,136 KB
testcase_10 AC 186 ms
104,932 KB
testcase_11 AC 154 ms
95,676 KB
testcase_12 AC 119 ms
88,448 KB
testcase_13 AC 649 ms
123,464 KB
testcase_14 AC 698 ms
129,472 KB
testcase_15 AC 839 ms
139,140 KB
testcase_16 AC 422 ms
105,728 KB
testcase_17 AC 823 ms
141,260 KB
testcase_18 AC 295 ms
96,192 KB
testcase_19 AC 825 ms
139,856 KB
testcase_20 AC 256 ms
92,936 KB
testcase_21 AC 342 ms
102,016 KB
testcase_22 AC 720 ms
133,668 KB
testcase_23 AC 55 ms
66,176 KB
testcase_24 AC 61 ms
69,248 KB
testcase_25 AC 120 ms
88,448 KB
testcase_26 AC 476 ms
112,020 KB
testcase_27 AC 439 ms
109,732 KB
testcase_28 AC 723 ms
131,712 KB
testcase_29 AC 153 ms
83,448 KB
testcase_30 AC 731 ms
138,660 KB
testcase_31 AC 524 ms
120,560 KB
testcase_32 AC 384 ms
104,676 KB
testcase_33 AC 794 ms
139,156 KB
testcase_34 AC 301 ms
97,940 KB
testcase_35 AC 837 ms
143,520 KB
testcase_36 AC 66 ms
70,656 KB
testcase_37 AC 91 ms
77,248 KB
testcase_38 AC 83 ms
77,092 KB
testcase_39 AC 98 ms
77,632 KB
testcase_40 AC 53 ms
63,744 KB
testcase_41 AC 851 ms
142,668 KB
testcase_42 AC 294 ms
97,048 KB
testcase_43 AC 474 ms
111,720 KB
testcase_44 AC 221 ms
89,912 KB
testcase_45 AC 451 ms
110,260 KB
testcase_46 AC 39 ms
52,748 KB
testcase_47 AC 40 ms
52,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,M=map(int,input().split())
X,Y=map(int,input().split())
L=[tuple(map(int,input().split())) for i in range(N)]
E=[[] for i in range(N+1)]

from math import sqrt

for i in range(M):
    p,q=map(int,input().split())
    p-=1
    q-=1
    x0,y0=L[p]
    x1,y1=L[q]
    E[p].append((sqrt((x0-x1)**2+(y0-y1)**2),q))
    E[q].append((sqrt((x0-x1)**2+(y0-y1)**2),p))

import heapq
DP=[1<<62]*(N+1)
DP[X-1]=0

Q=[(0,X-1)]

while Q:
    now,x=heapq.heappop(Q)

    for le,to in E[x]:
        if DP[to]>DP[x]+le:
            DP[to]=DP[x]+le
            heapq.heappush(Q,(DP[to]+le,to))
print(DP[Y-1])
    
    
    
    
0