結果

問題 No.1382 Travel in Mitaru city
ユーザー H3PO4H3PO4
提出日時 2021-02-07 21:54:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 396 ms / 2,000 ms
コード長 580 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 99,708 KB
最終ジャッジ日時 2023-09-17 21:25:12
合計ジャッジ時間 20,771 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,384 KB
testcase_01 AC 78 ms
71,292 KB
testcase_02 AC 79 ms
71,312 KB
testcase_03 AC 81 ms
71,432 KB
testcase_04 AC 80 ms
71,376 KB
testcase_05 AC 80 ms
71,348 KB
testcase_06 AC 193 ms
82,744 KB
testcase_07 AC 192 ms
82,008 KB
testcase_08 AC 173 ms
80,168 KB
testcase_09 AC 210 ms
83,796 KB
testcase_10 AC 187 ms
83,408 KB
testcase_11 AC 265 ms
88,264 KB
testcase_12 AC 289 ms
88,416 KB
testcase_13 AC 300 ms
88,820 KB
testcase_14 AC 263 ms
88,272 KB
testcase_15 AC 256 ms
88,204 KB
testcase_16 AC 346 ms
96,020 KB
testcase_17 AC 332 ms
95,624 KB
testcase_18 AC 347 ms
96,024 KB
testcase_19 AC 338 ms
95,856 KB
testcase_20 AC 350 ms
95,788 KB
testcase_21 AC 377 ms
95,772 KB
testcase_22 AC 367 ms
95,988 KB
testcase_23 AC 373 ms
95,660 KB
testcase_24 AC 355 ms
95,900 KB
testcase_25 AC 354 ms
95,668 KB
testcase_26 AC 395 ms
95,908 KB
testcase_27 AC 396 ms
95,728 KB
testcase_28 AC 392 ms
95,820 KB
testcase_29 AC 393 ms
96,028 KB
testcase_30 AC 357 ms
95,964 KB
testcase_31 AC 227 ms
93,008 KB
testcase_32 AC 259 ms
95,696 KB
testcase_33 AC 240 ms
95,212 KB
testcase_34 AC 195 ms
88,340 KB
testcase_35 AC 171 ms
85,080 KB
testcase_36 AC 178 ms
93,360 KB
testcase_37 AC 111 ms
78,860 KB
testcase_38 AC 186 ms
95,076 KB
testcase_39 AC 116 ms
80,532 KB
testcase_40 AC 167 ms
89,572 KB
testcase_41 AC 163 ms
91,520 KB
testcase_42 AC 173 ms
95,568 KB
testcase_43 AC 174 ms
92,888 KB
testcase_44 AC 130 ms
82,964 KB
testcase_45 AC 164 ms
90,964 KB
testcase_46 AC 201 ms
83,696 KB
testcase_47 AC 375 ms
98,040 KB
testcase_48 AC 302 ms
92,988 KB
testcase_49 AC 391 ms
99,708 KB
testcase_50 AC 237 ms
89,364 KB
testcase_51 AC 210 ms
93,004 KB
testcase_52 AC 232 ms
95,784 KB
testcase_53 AC 135 ms
81,536 KB
testcase_54 AC 157 ms
85,984 KB
testcase_55 AC 221 ms
95,464 KB
testcase_56 AC 139 ms
83,068 KB
testcase_57 AC 191 ms
89,608 KB
testcase_58 AC 114 ms
78,644 KB
testcase_59 AC 144 ms
82,880 KB
testcase_60 AC 233 ms
95,020 KB
testcase_61 AC 99 ms
76,460 KB
testcase_62 AC 74 ms
71,324 KB
testcase_63 AC 101 ms
77,444 KB
testcase_64 AC 94 ms
76,540 KB
testcase_65 AC 86 ms
76,152 KB
testcase_66 AC 90 ms
76,464 KB
testcase_67 AC 90 ms
76,496 KB
testcase_68 AC 94 ms
77,316 KB
testcase_69 AC 89 ms
76,308 KB
testcase_70 AC 94 ms
77,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import heapq

input = sys.stdin.buffer.readline

N, M, S, T = map(int, input().split())
S -= 1
T -= 1
P = tuple(map(int, input().split()))
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = (int(x) - 1 for x in input().split())
    G[a].append(b)
    G[b].append(a)

h = [(-P[S], S)]
nonvisited = [True] * N
nonvisited[S] = False
ans = 0
X = P[S]
while h:
    p, v = heapq.heappop(h)
    if -p < X:
        X = -p
        ans += 1
    for x in G[v]:
        if nonvisited[x]:
            heapq.heappush(h, (-P[x], x))
            nonvisited[x] = False
print(ans)
0