結果

問題 No.1382 Travel in Mitaru city
ユーザー Akijin_007Akijin_007
提出日時 2023-08-31 19:55:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 399 ms / 2,000 ms
コード長 845 bytes
コンパイル時間 593 ms
コンパイル使用メモリ 86,452 KB
実行使用メモリ 98,280 KB
最終ジャッジ日時 2023-08-31 19:55:56
合計ジャッジ時間 22,803 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
71,236 KB
testcase_01 AC 73 ms
71,168 KB
testcase_02 AC 75 ms
71,216 KB
testcase_03 AC 74 ms
70,996 KB
testcase_04 AC 73 ms
71,072 KB
testcase_05 AC 73 ms
71,024 KB
testcase_06 AC 221 ms
82,100 KB
testcase_07 AC 204 ms
81,328 KB
testcase_08 AC 159 ms
79,044 KB
testcase_09 AC 241 ms
83,068 KB
testcase_10 AC 210 ms
82,740 KB
testcase_11 AC 264 ms
87,596 KB
testcase_12 AC 282 ms
87,660 KB
testcase_13 AC 300 ms
88,092 KB
testcase_14 AC 273 ms
87,648 KB
testcase_15 AC 250 ms
87,736 KB
testcase_16 AC 360 ms
94,616 KB
testcase_17 AC 399 ms
94,660 KB
testcase_18 AC 353 ms
94,684 KB
testcase_19 AC 327 ms
94,560 KB
testcase_20 AC 398 ms
94,564 KB
testcase_21 AC 336 ms
94,744 KB
testcase_22 AC 326 ms
95,100 KB
testcase_23 AC 317 ms
94,452 KB
testcase_24 AC 375 ms
94,792 KB
testcase_25 AC 319 ms
94,744 KB
testcase_26 AC 259 ms
94,456 KB
testcase_27 AC 353 ms
94,540 KB
testcase_28 AC 270 ms
94,980 KB
testcase_29 AC 271 ms
94,688 KB
testcase_30 AC 266 ms
94,484 KB
testcase_31 AC 212 ms
92,140 KB
testcase_32 AC 262 ms
94,716 KB
testcase_33 AC 216 ms
94,384 KB
testcase_34 AC 181 ms
87,524 KB
testcase_35 AC 158 ms
84,404 KB
testcase_36 AC 179 ms
92,144 KB
testcase_37 AC 115 ms
78,052 KB
testcase_38 AC 217 ms
94,232 KB
testcase_39 AC 133 ms
81,692 KB
testcase_40 AC 162 ms
89,012 KB
testcase_41 AC 175 ms
90,760 KB
testcase_42 AC 189 ms
94,360 KB
testcase_43 AC 174 ms
92,260 KB
testcase_44 AC 135 ms
83,084 KB
testcase_45 AC 171 ms
90,628 KB
testcase_46 AC 203 ms
83,352 KB
testcase_47 AC 307 ms
95,340 KB
testcase_48 AC 266 ms
91,408 KB
testcase_49 AC 348 ms
98,280 KB
testcase_50 AC 252 ms
86,992 KB
testcase_51 AC 214 ms
91,264 KB
testcase_52 AC 232 ms
93,816 KB
testcase_53 AC 134 ms
81,800 KB
testcase_54 AC 163 ms
86,040 KB
testcase_55 AC 227 ms
93,884 KB
testcase_56 AC 143 ms
82,832 KB
testcase_57 AC 176 ms
88,256 KB
testcase_58 AC 118 ms
78,112 KB
testcase_59 AC 145 ms
83,212 KB
testcase_60 AC 227 ms
93,572 KB
testcase_61 AC 102 ms
77,296 KB
testcase_62 AC 73 ms
71,116 KB
testcase_63 AC 118 ms
77,316 KB
testcase_64 AC 104 ms
77,208 KB
testcase_65 AC 88 ms
75,648 KB
testcase_66 AC 104 ms
77,468 KB
testcase_67 AC 106 ms
78,016 KB
testcase_68 AC 106 ms
77,220 KB
testcase_69 AC 100 ms
77,272 KB
testcase_70 AC 103 ms
77,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#int(input())
#map(int, input().split())
#list(map(int, input().split()))

N, M, S, T = map(int, input().split())
p = list(map(int, input().split()))

to = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    to[a-1].append(b-1)
    to[b-1].append(a-1)

S -= 1
T -= 1

import heapq
q = [(-p[S], S)]
X = p[S]
a = []
v = [0] * N
v[S] = 1

heapq.heapify(q)

while q:
    t, x = heapq.heappop(q)
    t *= -1
    qq = [x]
    a.append(t)
    # if x == T:
    #     break

    while qq:
        u = qq.pop()
        for y in to[u]:
            if v[y] == 1:
                continue
            if p[y] >= t:
                qq.append(y)
            else:
                heapq.heappush(q, (-p[y], y))
            v[y] = 1

ans = 0
for i in range(len(a)-1):
    if a[i] > a[i+1]:
        ans += 1

print(ans)












0