結果

問題 No.2431 Viral Hotel
ユーザー tassei903tassei903
提出日時 2023-08-16 07:44:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 446 ms / 2,000 ms
コード長 1,043 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 97,444 KB
最終ジャッジ日時 2024-05-03 16:43:02
合計ジャッジ時間 13,504 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 341 ms
92,480 KB
testcase_01 AC 307 ms
90,560 KB
testcase_02 AC 352 ms
91,036 KB
testcase_03 AC 381 ms
93,980 KB
testcase_04 AC 341 ms
93,760 KB
testcase_05 AC 414 ms
96,000 KB
testcase_06 AC 104 ms
78,880 KB
testcase_07 AC 105 ms
78,928 KB
testcase_08 AC 103 ms
78,620 KB
testcase_09 AC 39 ms
53,248 KB
testcase_10 AC 38 ms
52,992 KB
testcase_11 AC 38 ms
52,736 KB
testcase_12 AC 446 ms
97,444 KB
testcase_13 AC 398 ms
92,876 KB
testcase_14 AC 278 ms
86,628 KB
testcase_15 AC 186 ms
80,128 KB
testcase_16 AC 269 ms
89,452 KB
testcase_17 AC 255 ms
84,964 KB
testcase_18 AC 369 ms
92,544 KB
testcase_19 AC 329 ms
89,028 KB
testcase_20 AC 210 ms
83,404 KB
testcase_21 AC 225 ms
82,200 KB
testcase_22 AC 302 ms
87,520 KB
testcase_23 AC 304 ms
87,620 KB
testcase_24 AC 261 ms
86,204 KB
testcase_25 AC 355 ms
91,444 KB
testcase_26 AC 290 ms
87,952 KB
testcase_27 AC 249 ms
87,264 KB
testcase_28 AC 276 ms
86,016 KB
testcase_29 AC 248 ms
85,388 KB
testcase_30 AC 278 ms
86,784 KB
testcase_31 AC 322 ms
89,960 KB
testcase_32 AC 228 ms
81,524 KB
testcase_33 AC 259 ms
85,596 KB
testcase_34 AC 144 ms
78,208 KB
testcase_35 AC 211 ms
80,904 KB
testcase_36 AC 401 ms
92,284 KB
testcase_37 AC 262 ms
87,424 KB
testcase_38 AC 204 ms
84,512 KB
testcase_39 AC 37 ms
52,992 KB
testcase_40 AC 37 ms
52,864 KB
testcase_41 AC 38 ms
52,864 KB
testcase_42 AC 38 ms
52,864 KB
testcase_43 AC 361 ms
95,956 KB
testcase_44 AC 321 ms
89,824 KB
testcase_45 AC 257 ms
86,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
n, k, m, p = na()
g = [[]for i in range(n)]
inf = float("inf")
for _ in range(m):
    u,v = na()
    u-=1
    v-=1
    g[u].append(v)
    g[v].append(u)

s = [ni() for i in range(n)]
x = [ni()-1 for i in range(k)]

from heapq import *
hq = []
# 検疫されたか
f = [-1] * n
# いつ感染したか
d = [inf] * n
for i in range(k):
    heappush(hq, (s[x[i]], x[i]))
    d[x[i]] = 0
ans = 0
while hq:
    #print(hq,f,d)
    t, v = heappop(hq)
    if f[v] != -1 and f[v] < t:
        continue
    for u in g[v]:
        if d[u] == inf:
            d[u] = t
            heappush(hq, (t+s[u], u))
        elif t - d[u] < p and f[u] == -1:
            f[u] = t
            ans += 1

print(ans)
0