結果

問題 No.2431 Viral Hotel
ユーザー bortikbortik
提出日時 2023-08-15 04:22:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 591 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 96,184 KB
最終ジャッジ日時 2024-05-02 18:41:39
合計ジャッジ時間 18,144 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 437 ms
91,808 KB
testcase_01 AC 429 ms
89,844 KB
testcase_02 AC 425 ms
90,756 KB
testcase_03 AC 468 ms
93,496 KB
testcase_04 AC 518 ms
93,968 KB
testcase_05 AC 582 ms
96,000 KB
testcase_06 AC 149 ms
78,976 KB
testcase_07 AC 147 ms
78,464 KB
testcase_08 AC 140 ms
78,464 KB
testcase_09 AC 43 ms
52,608 KB
testcase_10 AC 43 ms
52,608 KB
testcase_11 AC 43 ms
52,480 KB
testcase_12 AC 591 ms
96,184 KB
testcase_13 AC 516 ms
92,928 KB
testcase_14 AC 327 ms
86,180 KB
testcase_15 AC 224 ms
80,128 KB
testcase_16 AC 374 ms
88,192 KB
testcase_17 AC 331 ms
84,352 KB
testcase_18 AC 507 ms
92,576 KB
testcase_19 AC 438 ms
88,912 KB
testcase_20 AC 302 ms
84,252 KB
testcase_21 AC 272 ms
81,408 KB
testcase_22 AC 398 ms
87,160 KB
testcase_23 AC 446 ms
88,084 KB
testcase_24 AC 350 ms
86,080 KB
testcase_25 AC 509 ms
92,056 KB
testcase_26 AC 334 ms
87,324 KB
testcase_27 AC 427 ms
87,516 KB
testcase_28 AC 388 ms
85,876 KB
testcase_29 AC 355 ms
85,568 KB
testcase_30 AC 374 ms
85,760 KB
testcase_31 AC 446 ms
90,496 KB
testcase_32 AC 285 ms
81,028 KB
testcase_33 AC 355 ms
84,768 KB
testcase_34 AC 185 ms
78,764 KB
testcase_35 AC 254 ms
81,264 KB
testcase_36 AC 510 ms
91,776 KB
testcase_37 AC 390 ms
86,400 KB
testcase_38 AC 266 ms
83,960 KB
testcase_39 AC 43 ms
52,480 KB
testcase_40 AC 43 ms
52,608 KB
testcase_41 AC 43 ms
52,864 KB
testcase_42 AC 42 ms
52,736 KB
testcase_43 AC 498 ms
95,684 KB
testcase_44 AC 425 ms
89,472 KB
testcase_45 AC 356 ms
86,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

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

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

for i in range(M):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    adj[u].append(v)
    adj[v].append(u)

s = [int(input()) for _ in range(N)]

infected = [-1 for _ in range(N)]

todo = []
heapq.heapify(todo)

for i in range(K):
    x = int(input())
    x -= 1
    infected[x] = 0
    heapq.heappush(todo, (s[x], x))

quar = [-1 for _ in range(N)]
answer = 0

while todo:
    x = heapq.heappop(todo)
    if quar[x[1]] != -1 and quar[x[1]] < x[0]: continue
    for u in adj[x[1]]:
        if infected[u] == -1:
            infected[u] = x[0]
            heapq.heappush(todo, (x[0]+s[u], u))
        else:
            if infected[u] + P > x[0] and quar[u] == -1:
                quar[u] = x[0]
                answer += 1

print(answer)
0