結果

問題 No.1382 Travel in Mitaru city
ユーザー rlangevinrlangevin
提出日時 2023-04-13 12:47:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 376 ms / 2,000 ms
コード長 622 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 82,196 KB
実行使用メモリ 96,108 KB
最終ジャッジ日時 2024-04-17 16:54:31
合計ジャッジ時間 15,077 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,608 KB
testcase_01 AC 36 ms
52,864 KB
testcase_02 AC 35 ms
52,992 KB
testcase_03 AC 34 ms
52,992 KB
testcase_04 AC 33 ms
52,964 KB
testcase_05 AC 32 ms
52,480 KB
testcase_06 AC 223 ms
84,352 KB
testcase_07 AC 182 ms
82,136 KB
testcase_08 AC 164 ms
79,360 KB
testcase_09 AC 224 ms
84,480 KB
testcase_10 AC 210 ms
84,468 KB
testcase_11 AC 241 ms
86,912 KB
testcase_12 AC 304 ms
87,028 KB
testcase_13 AC 328 ms
87,324 KB
testcase_14 AC 232 ms
86,784 KB
testcase_15 AC 283 ms
86,784 KB
testcase_16 AC 310 ms
94,136 KB
testcase_17 AC 344 ms
93,568 KB
testcase_18 AC 366 ms
93,568 KB
testcase_19 AC 314 ms
94,336 KB
testcase_20 AC 333 ms
93,952 KB
testcase_21 AC 304 ms
94,080 KB
testcase_22 AC 362 ms
93,700 KB
testcase_23 AC 376 ms
94,148 KB
testcase_24 AC 347 ms
93,952 KB
testcase_25 AC 298 ms
94,336 KB
testcase_26 AC 328 ms
93,844 KB
testcase_27 AC 357 ms
93,696 KB
testcase_28 AC 324 ms
93,708 KB
testcase_29 AC 328 ms
93,844 KB
testcase_30 AC 303 ms
94,080 KB
testcase_31 AC 137 ms
91,856 KB
testcase_32 AC 161 ms
93,568 KB
testcase_33 AC 154 ms
93,440 KB
testcase_34 AC 120 ms
86,784 KB
testcase_35 AC 104 ms
83,072 KB
testcase_36 AC 113 ms
92,032 KB
testcase_37 AC 66 ms
77,952 KB
testcase_38 AC 121 ms
93,184 KB
testcase_39 AC 72 ms
80,036 KB
testcase_40 AC 100 ms
88,224 KB
testcase_41 AC 106 ms
89,600 KB
testcase_42 AC 115 ms
93,312 KB
testcase_43 AC 117 ms
91,136 KB
testcase_44 AC 77 ms
81,280 KB
testcase_45 AC 104 ms
89,344 KB
testcase_46 AC 141 ms
82,176 KB
testcase_47 AC 273 ms
96,028 KB
testcase_48 AC 216 ms
90,956 KB
testcase_49 AC 300 ms
96,108 KB
testcase_50 AC 179 ms
85,720 KB
testcase_51 AC 141 ms
91,248 KB
testcase_52 AC 153 ms
93,476 KB
testcase_53 AC 82 ms
79,780 KB
testcase_54 AC 104 ms
84,608 KB
testcase_55 AC 145 ms
92,800 KB
testcase_56 AC 90 ms
81,492 KB
testcase_57 AC 122 ms
87,264 KB
testcase_58 AC 73 ms
78,124 KB
testcase_59 AC 91 ms
81,280 KB
testcase_60 AC 142 ms
93,312 KB
testcase_61 AC 97 ms
76,900 KB
testcase_62 AC 35 ms
52,864 KB
testcase_63 AC 134 ms
78,016 KB
testcase_64 AC 104 ms
77,440 KB
testcase_65 AC 56 ms
68,864 KB
testcase_66 AC 102 ms
77,368 KB
testcase_67 AC 101 ms
77,120 KB
testcase_68 AC 107 ms
77,440 KB
testcase_69 AC 99 ms
77,056 KB
testcase_70 AC 114 ms
77,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline
from heapq import *

N, M, S, T = map(int, readline().split())
S, T = S - 1, T - 1
P = list(map(int, readline().split()))
G = [[] for i in range(N)]
for i in range(M):
    A, B = map(int, readline().split())
    A, B = A - 1, B - 1
    G[A].append(B)
    G[B].append(A)

Q = []
Q.append((-P[S], S))
ans = -1
now = 10 ** 18
seen = [0] * N
while Q:
    c, u = heappop(Q)
    c = -c
    if seen[u]:
        continue
    seen[u] = 1
    if c < now:
        ans += 1
        now = c
    for v in G[u]:
        if seen[v]:
            continue
        heappush(Q, (-P[v], v))

print(ans)
0