結果

問題 No.2431 Viral Hotel
ユーザー bortikbortik
提出日時 2023-08-15 04:21:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,122 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 41,856 KB
最終ジャッジ日時 2024-05-02 18:42:09
合計ジャッジ時間 24,469 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 835 ms
33,408 KB
testcase_01 AC 727 ms
29,312 KB
testcase_02 AC 739 ms
30,464 KB
testcase_03 AC 832 ms
31,232 KB
testcase_04 AC 897 ms
35,072 KB
testcase_05 AC 1,028 ms
36,096 KB
testcase_06 AC 341 ms
15,232 KB
testcase_07 AC 328 ms
15,488 KB
testcase_08 AC 332 ms
15,360 KB
testcase_09 AC 27 ms
10,880 KB
testcase_10 AC 26 ms
10,624 KB
testcase_11 AC 28 ms
10,880 KB
testcase_12 AC 1,122 ms
41,856 KB
testcase_13 AC 834 ms
33,792 KB
testcase_14 AC 445 ms
23,424 KB
testcase_15 AC 193 ms
15,232 KB
testcase_16 AC 602 ms
28,288 KB
testcase_17 AC 368 ms
20,224 KB
testcase_18 AC 874 ms
34,432 KB
testcase_19 AC 618 ms
27,776 KB
testcase_20 AC 289 ms
19,712 KB
testcase_21 AC 225 ms
17,152 KB
testcase_22 AC 548 ms
25,472 KB
testcase_23 AC 574 ms
25,856 KB
testcase_24 AC 372 ms
22,784 KB
testcase_25 AC 738 ms
31,360 KB
testcase_26 AC 490 ms
25,600 KB
testcase_27 AC 542 ms
25,216 KB
testcase_28 AC 434 ms
22,784 KB
testcase_29 AC 426 ms
22,144 KB
testcase_30 AC 510 ms
24,192 KB
testcase_31 AC 680 ms
29,312 KB
testcase_32 AC 224 ms
16,384 KB
testcase_33 AC 414 ms
21,760 KB
testcase_34 AC 71 ms
12,288 KB
testcase_35 AC 157 ms
14,976 KB
testcase_36 AC 757 ms
31,872 KB
testcase_37 AC 514 ms
25,600 KB
testcase_38 AC 284 ms
20,224 KB
testcase_39 AC 27 ms
10,752 KB
testcase_40 AC 27 ms
10,752 KB
testcase_41 AC 25 ms
10,880 KB
testcase_42 AC 25 ms
10,752 KB
testcase_43 AC 1,007 ms
38,144 KB
testcase_44 AC 639 ms
28,544 KB
testcase_45 AC 434 ms
23,296 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