結果

問題 No.2431 Viral Hotel
ユーザー 0214sh70214sh7
提出日時 2023-08-14 20:30:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,464 ms / 2,000 ms
コード長 1,489 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 115,488 KB
最終ジャッジ日時 2024-05-02 18:41:01
合計ジャッジ時間 30,999 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,066 ms
106,840 KB
testcase_01 AC 930 ms
101,772 KB
testcase_02 AC 931 ms
103,680 KB
testcase_03 AC 1,071 ms
109,248 KB
testcase_04 AC 1,078 ms
109,440 KB
testcase_05 AC 1,277 ms
111,444 KB
testcase_06 AC 175 ms
79,744 KB
testcase_07 AC 151 ms
79,104 KB
testcase_08 AC 144 ms
78,720 KB
testcase_09 AC 38 ms
52,608 KB
testcase_10 AC 39 ms
52,864 KB
testcase_11 AC 42 ms
52,224 KB
testcase_12 AC 1,464 ms
115,488 KB
testcase_13 AC 1,013 ms
107,596 KB
testcase_14 AC 624 ms
93,936 KB
testcase_15 AC 306 ms
82,688 KB
testcase_16 AC 902 ms
101,744 KB
testcase_17 AC 516 ms
89,728 KB
testcase_18 AC 1,137 ms
106,696 KB
testcase_19 AC 820 ms
99,092 KB
testcase_20 AC 425 ms
87,792 KB
testcase_21 AC 374 ms
85,120 KB
testcase_22 AC 694 ms
95,136 KB
testcase_23 AC 725 ms
97,964 KB
testcase_24 AC 471 ms
91,240 KB
testcase_25 AC 940 ms
103,424 KB
testcase_26 AC 668 ms
96,100 KB
testcase_27 AC 741 ms
96,652 KB
testcase_28 AC 639 ms
92,672 KB
testcase_29 AC 604 ms
92,160 KB
testcase_30 AC 636 ms
93,696 KB
testcase_31 AC 880 ms
101,376 KB
testcase_32 AC 340 ms
83,672 KB
testcase_33 AC 550 ms
90,624 KB
testcase_34 AC 189 ms
79,112 KB
testcase_35 AC 288 ms
82,936 KB
testcase_36 AC 1,078 ms
105,624 KB
testcase_37 AC 778 ms
96,212 KB
testcase_38 AC 359 ms
86,972 KB
testcase_39 AC 40 ms
52,608 KB
testcase_40 AC 39 ms
52,608 KB
testcase_41 AC 39 ms
52,608 KB
testcase_42 AC 41 ms
52,736 KB
testcase_43 AC 1,354 ms
112,776 KB
testcase_44 AC 860 ms
99,576 KB
testcase_45 AC 634 ms
94,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

N,K,M,P = map(int,input().split())
G = [ [] for _ in range(N)]
for i 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)]

# {イベントが起こる日,イベントの種類,起こる頂点}
que = []
heapq.heapify(que)
Ans = 0

#回復したか
recovered = [False]*N
#検疫が入ったか
quarantined = [False]*N
#いま感染しているか
infected = [False]*N

#0: 回復 1: 隣に感染 2:検疫 
for i in range(K):
    infected[X[i]] = True
    heapq.heappush(que, [P,0,X[i]])
    heapq.heappush(que, [S[X[i]],1,X[i]])

while len(que)>0:
    q = heapq.heappop(que)

    #検疫が入った場合その後一切のアクションを起こさない
    if quarantined[q[2]]:
        continue

    if q[1] == 0:
        #回復
        infected[q[2]] = False
        recovered[q[2]] = True
    elif q[1] == 1:
        #隣にうつす
        for e in G[q[2]]:
            if recovered[e] or quarantined[e]:
                continue
            #すでにかかっていた場合検疫送り
            if infected[e]:
                heapq.heappush(que, [q[0],2,e])
            else:
                infected[e] = True
                heapq.heappush(que, [q[0]+P,0,e])
                heapq.heappush(que, [q[0]+S[e],1,e])
    else:
        #検疫
        Ans += 1
        infected[q[2]] = False
        quarantined[q[2]] = True

print(Ans)
0