結果

問題 No.1382 Travel in Mitaru city
ユーザー tobusakanatobusakana
提出日時 2022-12-01 21:31:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 464 ms / 2,000 ms
コード長 834 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 96,448 KB
最終ジャッジ日時 2024-04-17 09:16:16
合計ジャッジ時間 17,725 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,992 KB
testcase_01 AC 40 ms
52,736 KB
testcase_02 AC 37 ms
52,864 KB
testcase_03 AC 37 ms
52,820 KB
testcase_04 AC 38 ms
52,480 KB
testcase_05 AC 38 ms
52,352 KB
testcase_06 AC 256 ms
84,480 KB
testcase_07 AC 230 ms
82,528 KB
testcase_08 AC 204 ms
80,000 KB
testcase_09 AC 267 ms
85,248 KB
testcase_10 AC 242 ms
84,756 KB
testcase_11 AC 275 ms
87,008 KB
testcase_12 AC 330 ms
87,344 KB
testcase_13 AC 392 ms
88,236 KB
testcase_14 AC 280 ms
86,844 KB
testcase_15 AC 328 ms
86,732 KB
testcase_16 AC 354 ms
94,080 KB
testcase_17 AC 403 ms
93,952 KB
testcase_18 AC 408 ms
94,084 KB
testcase_19 AC 359 ms
94,336 KB
testcase_20 AC 393 ms
93,952 KB
testcase_21 AC 427 ms
94,336 KB
testcase_22 AC 464 ms
94,080 KB
testcase_23 AC 437 ms
93,824 KB
testcase_24 AC 422 ms
94,252 KB
testcase_25 AC 367 ms
93,952 KB
testcase_26 AC 397 ms
94,464 KB
testcase_27 AC 421 ms
93,696 KB
testcase_28 AC 395 ms
93,952 KB
testcase_29 AC 423 ms
94,132 KB
testcase_30 AC 366 ms
94,080 KB
testcase_31 AC 179 ms
91,320 KB
testcase_32 AC 210 ms
93,952 KB
testcase_33 AC 192 ms
93,796 KB
testcase_34 AC 151 ms
86,916 KB
testcase_35 AC 125 ms
83,676 KB
testcase_36 AC 136 ms
91,332 KB
testcase_37 AC 78 ms
77,952 KB
testcase_38 AC 142 ms
93,592 KB
testcase_39 AC 85 ms
80,000 KB
testcase_40 AC 121 ms
88,448 KB
testcase_41 AC 127 ms
90,016 KB
testcase_42 AC 140 ms
93,512 KB
testcase_43 AC 130 ms
91,520 KB
testcase_44 AC 91 ms
81,792 KB
testcase_45 AC 125 ms
89,484 KB
testcase_46 AC 163 ms
82,560 KB
testcase_47 AC 332 ms
95,624 KB
testcase_48 AC 264 ms
90,996 KB
testcase_49 AC 361 ms
96,448 KB
testcase_50 AC 207 ms
85,908 KB
testcase_51 AC 176 ms
90,880 KB
testcase_52 AC 193 ms
93,228 KB
testcase_53 AC 102 ms
79,744 KB
testcase_54 AC 130 ms
84,748 KB
testcase_55 AC 188 ms
92,928 KB
testcase_56 AC 105 ms
82,176 KB
testcase_57 AC 154 ms
87,296 KB
testcase_58 AC 84 ms
77,800 KB
testcase_59 AC 115 ms
81,548 KB
testcase_60 AC 195 ms
92,928 KB
testcase_61 AC 119 ms
77,440 KB
testcase_62 AC 40 ms
52,608 KB
testcase_63 AC 180 ms
78,944 KB
testcase_64 AC 137 ms
77,568 KB
testcase_65 AC 65 ms
68,224 KB
testcase_66 AC 127 ms
77,504 KB
testcase_67 AC 132 ms
77,440 KB
testcase_68 AC 131 ms
77,440 KB
testcase_69 AC 128 ms
77,288 KB
testcase_70 AC 152 ms
77,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 常に、今まで訪れた頂点集合からいける場所のうち最も数値が小さい場所に移動する。
# heapqに、(行ける場所の数値)を入れて移動する

import sys
readline = sys.stdin.readline
N,M,S,T = map(int,readline().split())
S -= 1
T -= 1
P = list(map(int,readline().split()))
G = [[] for i in range(N)]
for _ in range(M):
    a,b = map(int,readline().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)

import heapq as hq
q = []
hq.heappush(q, (-P[S], S))
visited = [False] * N
X = P[S]
ans = 0
while q:
    p, v = hq.heappop(q)
    p *= (-1)
    if visited[v]:
        continue
    visited[v] = True
    if p < X:
        ans += 1
        X = p
    for child in G[v]:
        if visited[child]:
            continue
        hq.heappush(q, (-P[child], child))
        
print(ans)


0