結果

問題 No.2431 Viral Hotel
ユーザー sotanishy
提出日時 2023-08-18 22:45:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 769 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 96,352 KB
最終ジャッジ日時 2024-11-28 08:55:23
合計ジャッジ時間 12,882 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 4 WA * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop
import sys
input = sys.stdin.readline


N,K,M,P=map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    u,v=map(int, input().split())
    u-=1
    v-=1
    G[u].append(v)
    G[v].append(u)
s = [int(input()) for _ in range(N)]
x = [int(input())-1 for _ in range(K)]
heap = []
INF = 10**10
infected = [INF] * N
removed = [0] * N
for y in x:
    infected[y] = 0
    heappush(heap, (s[y], y))
while heap:
    t, v = heappop(heap)
    if removed[v]:
        continue
    for u in G[v]:
        if t >= infected[u] + P or removed[u]:
            continue
        if infected[u] == INF:
            infected[u] = t
            heappush(heap, (t + s[u], u))
        else:
            removed[u] = 1
print(sum(removed))

0