結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー realDivineJKrealDivineJK
提出日時 2020-05-29 23:58:39
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 896 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 205,664 KB
最終ジャッジ日時 2024-04-24 02:36:08
合計ジャッジ時間 51,503 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,992 KB
testcase_01 AC 41 ms
52,864 KB
testcase_02 AC 1,341 ms
135,032 KB
testcase_03 AC 1,841 ms
199,344 KB
testcase_04 AC 1,900 ms
197,164 KB
testcase_05 AC 1,679 ms
197,320 KB
testcase_06 AC 1,694 ms
197,324 KB
testcase_07 AC 680 ms
108,248 KB
testcase_08 TLE -
testcase_09 AC 309 ms
87,040 KB
testcase_10 AC 1,108 ms
128,796 KB
testcase_11 AC 761 ms
109,132 KB
testcase_12 AC 214 ms
96,400 KB
testcase_13 AC 1,448 ms
150,248 KB
testcase_14 AC 1,719 ms
159,788 KB
testcase_15 TLE -
testcase_16 AC 875 ms
122,320 KB
testcase_17 TLE -
testcase_18 AC 600 ms
105,848 KB
testcase_19 TLE -
testcase_20 AC 584 ms
102,404 KB
testcase_21 AC 694 ms
112,708 KB
testcase_22 AC 1,838 ms
170,168 KB
testcase_23 AC 85 ms
77,056 KB
testcase_24 AC 93 ms
78,464 KB
testcase_25 AC 196 ms
95,684 KB
testcase_26 AC 1,070 ms
129,380 KB
testcase_27 AC 1,046 ms
130,428 KB
testcase_28 AC 1,880 ms
176,072 KB
testcase_29 AC 266 ms
90,472 KB
testcase_30 AC 1,972 ms
182,004 KB
testcase_31 AC 1,395 ms
148,072 KB
testcase_32 AC 936 ms
120,744 KB
testcase_33 TLE -
testcase_34 AC 660 ms
110,540 KB
testcase_35 AC 1,989 ms
185,240 KB
testcase_36 AC 105 ms
77,056 KB
testcase_37 AC 171 ms
79,060 KB
testcase_38 AC 122 ms
78,976 KB
testcase_39 AC 171 ms
79,452 KB
testcase_40 AC 71 ms
70,400 KB
testcase_41 TLE -
testcase_42 AC 833 ms
109,276 KB
testcase_43 AC 1,388 ms
137,968 KB
testcase_44 AC 597 ms
100,580 KB
testcase_45 AC 1,386 ms
135,816 KB
testcase_46 AC 39 ms
52,992 KB
testcase_47 AC 37 ms
52,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop
N, M = map(int, input().split())
X, Y = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(N)]
D = {}
DD = {}
for i in range(M):
    P, Q = map(int, input().split())
    if P-1 in D:
        D[P-1].append(Q-1)
    else:
        D[P-1] = [Q-1]
    if Q-1 in D:
        D[Q-1].append(P-1)
    else:
        D[Q-1] = [P-1]
    DD[(P-1)*N+(Q-1)] = ((p[P-1][0]-p[Q-1][0])**2+(p[P-1][1]-p[Q-1][1])**2) ** 0.5
    DD[(Q-1)*N+(P-1)] = ((p[P-1][0]-p[Q-1][0])**2+(p[P-1][1]-p[Q-1][1])**2) ** 0.5
dist = [int(1e18) for _ in range(N)]
dist[X-1] = 0
pq = []
for i in range(N):
    heappush(pq, [dist[i], i])
while pq != []:
    b = heappop(pq)
    r = b[1]
    if r in D:
        for i in D[r]:
            if dist[i] > dist[r] + DD[r*N+i]:
                dist[i] = dist[r] + DD[r*N+i]
                heappush(pq, [dist[i], i])
print(dist[Y-1])
0