結果
| 問題 | 
                            No.1382 Travel in Mitaru city
                             | 
                    
| コンテスト | |
| ユーザー | 
                             rlangevin
                         | 
                    
| 提出日時 | 2023-04-13 12:45:45 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 659 bytes | 
| コンパイル時間 | 316 ms | 
| コンパイル使用メモリ | 82,364 KB | 
| 実行使用メモリ | 96,040 KB | 
| 最終ジャッジ日時 | 2024-10-09 11:00:59 | 
| 合計ジャッジ時間 | 18,971 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 57 WA * 11 | 
ソースコード
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
        if u == T:
            break
    for v in G[u]:
        if seen[v]:
            continue
        heappush(Q, (-P[v], v))
print(ans)
            
            
            
        
            
rlangevin