結果

問題 No.2431 Viral Hotel
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-08-19 03:45:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 491 ms / 2,000 ms
コード長 1,181 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 97,244 KB
最終ジャッジ日時 2024-05-06 10:55:36
合計ジャッジ時間 14,820 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 392 ms
91,724 KB
testcase_01 AC 352 ms
90,080 KB
testcase_02 AC 387 ms
90,904 KB
testcase_03 AC 408 ms
94,648 KB
testcase_04 AC 381 ms
94,108 KB
testcase_05 AC 473 ms
96,156 KB
testcase_06 AC 96 ms
77,312 KB
testcase_07 AC 95 ms
77,312 KB
testcase_08 AC 95 ms
77,056 KB
testcase_09 AC 42 ms
52,736 KB
testcase_10 AC 42 ms
52,736 KB
testcase_11 AC 43 ms
52,736 KB
testcase_12 AC 491 ms
97,244 KB
testcase_13 AC 432 ms
93,612 KB
testcase_14 AC 321 ms
86,948 KB
testcase_15 AC 200 ms
79,852 KB
testcase_16 AC 323 ms
88,744 KB
testcase_17 AC 287 ms
84,296 KB
testcase_18 AC 433 ms
92,332 KB
testcase_19 AC 387 ms
88,988 KB
testcase_20 AC 240 ms
84,372 KB
testcase_21 AC 263 ms
82,224 KB
testcase_22 AC 362 ms
87,812 KB
testcase_23 AC 344 ms
88,356 KB
testcase_24 AC 281 ms
86,532 KB
testcase_25 AC 420 ms
92,876 KB
testcase_26 AC 341 ms
88,712 KB
testcase_27 AC 282 ms
86,700 KB
testcase_28 AC 326 ms
85,956 KB
testcase_29 AC 280 ms
85,152 KB
testcase_30 AC 313 ms
86,076 KB
testcase_31 AC 356 ms
90,164 KB
testcase_32 AC 235 ms
81,260 KB
testcase_33 AC 286 ms
84,740 KB
testcase_34 AC 148 ms
78,080 KB
testcase_35 AC 211 ms
81,464 KB
testcase_36 AC 413 ms
92,312 KB
testcase_37 AC 288 ms
86,656 KB
testcase_38 AC 229 ms
84,112 KB
testcase_39 AC 42 ms
52,992 KB
testcase_40 AC 42 ms
52,224 KB
testcase_41 AC 42 ms
52,608 KB
testcase_42 AC 42 ms
52,608 KB
testcase_43 AC 411 ms
96,284 KB
testcase_44 AC 358 ms
88,852 KB
testcase_45 AC 290 ms
85,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

最短経路かな

他の人に感染させるタイミング昇順に見ればいい?

"""

import heapq
import sys
from sys import stdin

N,K,M,P = map(int,stdin.readline().split())

lis = [ [] for i in range(N) ]

for i in range(M):

    u,v = map(int,stdin.readline().split())
    u -= 1
    v -= 1

    lis[u].append(v)
    lis[v].append(u)

s = [int(stdin.readline()) for i in range(N)]

q = []
d = [float("inf")] * N
state = [0] * N

# 0=未感染
# 1=観戦
# 2=検疫

for i in range(K):

    x = int(stdin.readline())-1
    d[x] = 0
    state[x] = 1
    heapq.heappush(q , (d[x]+s[x] , x) )

ans = 0
second_time = [-1] * N

while q:

    itime,v = heapq.heappop(q)
    if itime != d[v] + s[v]:
        continue

    if state[v] == 2 and second_time[v] < itime:
        continue

    
    for nex in lis[v]:

        if d[nex] > d[v] + s[v]:
            d[nex] = d[v] + s[v]
            state[nex] = 1
            heapq.heappush( q , (d[nex]+s[nex] , nex) )

        elif state[nex] == 1 and d[nex] + P > d[v]+s[v]:
            state[nex] = 2
            second_time[nex] = d[v]+s[v]

ans = 0
for i in range(N):
    if state[i] == 2:
        ans += 1

print (ans)
0