結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー tanakkitanakki
提出日時 2020-05-29 22:39:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 890 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 117,968 KB
最終ジャッジ日時 2024-04-24 00:01:07
合計ジャッジ時間 22,513 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
52,864 KB
testcase_01 AC 45 ms
52,992 KB
testcase_02 AC 517 ms
96,624 KB
testcase_03 AC 788 ms
116,632 KB
testcase_04 AC 734 ms
116,232 KB
testcase_05 AC 485 ms
117,404 KB
testcase_06 AC 489 ms
117,968 KB
testcase_07 AC 195 ms
85,376 KB
testcase_08 AC 408 ms
113,552 KB
testcase_09 AC 139 ms
79,488 KB
testcase_10 AC 244 ms
91,808 KB
testcase_11 AC 204 ms
86,912 KB
testcase_12 AC 161 ms
78,976 KB
testcase_13 AC 683 ms
100,412 KB
testcase_14 AC 724 ms
106,660 KB
testcase_15 AC 879 ms
111,980 KB
testcase_16 AC 463 ms
90,500 KB
testcase_17 AC 890 ms
115,152 KB
testcase_18 AC 344 ms
84,924 KB
testcase_19 AC 833 ms
113,820 KB
testcase_20 AC 298 ms
84,920 KB
testcase_21 AC 388 ms
87,172 KB
testcase_22 AC 747 ms
108,684 KB
testcase_23 AC 85 ms
73,472 KB
testcase_24 AC 97 ms
77,440 KB
testcase_25 AC 156 ms
78,464 KB
testcase_26 AC 511 ms
95,488 KB
testcase_27 AC 486 ms
93,256 KB
testcase_28 AC 805 ms
106,956 KB
testcase_29 AC 219 ms
79,360 KB
testcase_30 AC 809 ms
112,672 KB
testcase_31 AC 577 ms
103,076 KB
testcase_32 AC 434 ms
92,592 KB
testcase_33 AC 851 ms
115,208 KB
testcase_34 AC 363 ms
87,136 KB
testcase_35 AC 846 ms
112,844 KB
testcase_36 AC 103 ms
77,312 KB
testcase_37 AC 156 ms
77,952 KB
testcase_38 AC 112 ms
76,928 KB
testcase_39 AC 150 ms
77,696 KB
testcase_40 AC 74 ms
67,072 KB
testcase_41 AC 857 ms
113,712 KB
testcase_42 AC 353 ms
87,624 KB
testcase_43 AC 498 ms
95,584 KB
testcase_44 AC 263 ms
84,096 KB
testcase_45 AC 501 ms
94,700 KB
testcase_46 AC 44 ms
52,736 KB
testcase_47 AC 43 ms
52,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
n, m = map(int, input().split())
x, y = map(int, input().split())
pq = []
for _ in range(n):
    p, q = map(int, input().split())
    pq.append((p, q))
graph = [[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split())
    graph[u-1].append(v-1)
    graph[v-1].append(u-1)
f = lambda a, b: ((a[0]-b[0])**2+(a[1]-b[1])**2)**0.5
INF = 10**9
heap = []
dist = [INF]*n
dist[x-1] = 0
heap = [(0, x-1)]
heapq.heapify(heap)
while heap:
    _, node = heapq.heappop(heap)
    for i in graph[node]:
        if dist[i] > dist[node] + f(pq[node], pq[i]):
            dist[i] = dist[node] + f(pq[node], pq[i])
            heapq.heappush(heap, (dist[i], i))
print(dist[y-1])
0