結果
問題 |
No.1382 Travel in Mitaru city
|
ユーザー |
|
提出日時 | 2023-08-31 19:55:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 352 ms / 2,000 ms |
コード長 | 845 bytes |
コンパイル時間 | 496 ms |
コンパイル使用メモリ | 82,472 KB |
実行使用メモリ | 96,780 KB |
最終ジャッジ日時 | 2025-01-03 04:48:24 |
合計ジャッジ時間 | 17,971 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 68 |
ソースコード
#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)