結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー ttrttr
提出日時 2020-05-29 21:51:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 774 bytes
コンパイル時間 593 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 114,048 KB
最終ジャッジ日時 2024-04-23 21:39:42
合計ジャッジ時間 50,810 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
11,008 KB
testcase_01 AC 27 ms
11,008 KB
testcase_02 AC 1,172 ms
61,952 KB
testcase_03 AC 1,963 ms
107,776 KB
testcase_04 AC 1,874 ms
106,624 KB
testcase_05 AC 1,844 ms
99,328 KB
testcase_06 AC 1,690 ms
99,328 KB
testcase_07 AC 447 ms
38,144 KB
testcase_08 AC 1,679 ms
114,048 KB
testcase_09 AC 162 ms
19,712 KB
testcase_10 AC 765 ms
56,832 KB
testcase_11 AC 509 ms
42,240 KB
testcase_12 AC 665 ms
38,656 KB
testcase_13 AC 1,537 ms
73,984 KB
testcase_14 AC 1,699 ms
82,432 KB
testcase_15 AC 1,949 ms
93,184 KB
testcase_16 AC 1,101 ms
55,168 KB
testcase_17 TLE -
testcase_18 AC 826 ms
44,800 KB
testcase_19 AC 1,932 ms
92,544 KB
testcase_20 AC 494 ms
34,432 KB
testcase_21 AC 1,037 ms
53,376 KB
testcase_22 AC 1,812 ms
87,680 KB
testcase_23 AC 49 ms
12,032 KB
testcase_24 AC 55 ms
12,288 KB
testcase_25 AC 569 ms
35,328 KB
testcase_26 AC 1,044 ms
57,396 KB
testcase_27 AC 1,150 ms
59,392 KB
testcase_28 AC 1,991 ms
90,708 KB
testcase_29 AC 302 ms
23,808 KB
testcase_30 AC 1,963 ms
93,580 KB
testcase_31 AC 1,258 ms
67,740 KB
testcase_32 AC 846 ms
49,920 KB
testcase_33 AC 1,843 ms
92,228 KB
testcase_34 AC 774 ms
44,800 KB
testcase_35 TLE -
testcase_36 AC 38 ms
11,392 KB
testcase_37 AC 44 ms
12,032 KB
testcase_38 AC 37 ms
11,648 KB
testcase_39 AC 42 ms
11,904 KB
testcase_40 AC 31 ms
11,264 KB
testcase_41 TLE -
testcase_42 AC 656 ms
42,496 KB
testcase_43 AC 1,218 ms
65,280 KB
testcase_44 AC 395 ms
30,848 KB
testcase_45 AC 1,145 ms
63,872 KB
testcase_46 AC 27 ms
10,880 KB
testcase_47 AC 26 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
N,M = map(int, input().split())
X,Y = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(N)]
E = [[] for _ in range(N)]
for _ in range(M):
    p,q = map(int, input().split())
    p -= 1
    q -= 1
    d = ((L[p][0]-L[q][0])**2 + (L[p][1]-L[q][1])**2)**0.5
    E[p].append((q, d))
    E[q].append((p, d))

def dijkstra(s):
    used = [0]*N
    inf = 10**10
    d = [inf]*N
    h = [(0, s)]
    while h:
        temp = heapq.heappop(h)
        u = temp[1]
        r = temp[0]
        if used[u] == 1:
            continue
        d[u] = r
        used[u] = 1
        for e in E[u]:
            if used[e[0]] == 1:
                continue
            heapq.heappush(h, (r+e[1], e[0]))
    return d[Y-1]

ans = dijkstra(X-1)
print(ans)
0