結果
問題 | No.2431 Viral Hotel |
ユーザー | chineristAC |
提出日時 | 2023-08-18 22:21:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,244 ms / 2,000 ms |
コード長 | 1,504 bytes |
コンパイル時間 | 397 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 114,460 KB |
最終ジャッジ日時 | 2024-11-28 08:04:58 |
合計ジャッジ時間 | 29,484 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 978 ms
104,572 KB |
testcase_01 | AC | 861 ms
100,416 KB |
testcase_02 | AC | 875 ms
102,140 KB |
testcase_03 | AC | 960 ms
107,188 KB |
testcase_04 | AC | 1,017 ms
108,288 KB |
testcase_05 | AC | 1,164 ms
110,292 KB |
testcase_06 | AC | 115 ms
78,336 KB |
testcase_07 | AC | 111 ms
78,208 KB |
testcase_08 | AC | 111 ms
78,464 KB |
testcase_09 | AC | 46 ms
52,608 KB |
testcase_10 | AC | 45 ms
52,480 KB |
testcase_11 | AC | 45 ms
52,352 KB |
testcase_12 | AC | 1,244 ms
114,460 KB |
testcase_13 | AC | 921 ms
105,252 KB |
testcase_14 | AC | 610 ms
93,568 KB |
testcase_15 | AC | 299 ms
82,728 KB |
testcase_16 | AC | 901 ms
101,140 KB |
testcase_17 | AC | 496 ms
88,832 KB |
testcase_18 | AC | 1,001 ms
105,028 KB |
testcase_19 | AC | 805 ms
98,908 KB |
testcase_20 | AC | 429 ms
87,616 KB |
testcase_21 | AC | 361 ms
85,248 KB |
testcase_22 | AC | 659 ms
93,600 KB |
testcase_23 | AC | 710 ms
96,188 KB |
testcase_24 | AC | 520 ms
91,052 KB |
testcase_25 | AC | 898 ms
103,024 KB |
testcase_26 | AC | 613 ms
95,488 KB |
testcase_27 | AC | 667 ms
95,264 KB |
testcase_28 | AC | 608 ms
91,904 KB |
testcase_29 | AC | 565 ms
92,424 KB |
testcase_30 | AC | 627 ms
92,980 KB |
testcase_31 | AC | 866 ms
101,032 KB |
testcase_32 | AC | 336 ms
84,352 KB |
testcase_33 | AC | 523 ms
89,600 KB |
testcase_34 | AC | 198 ms
78,828 KB |
testcase_35 | AC | 321 ms
83,428 KB |
testcase_36 | AC | 984 ms
104,576 KB |
testcase_37 | AC | 661 ms
94,812 KB |
testcase_38 | AC | 388 ms
87,056 KB |
testcase_39 | AC | 46 ms
52,352 KB |
testcase_40 | AC | 46 ms
52,608 KB |
testcase_41 | AC | 45 ms
52,352 KB |
testcase_42 | AC | 46 ms
52,736 KB |
testcase_43 | AC | 1,171 ms
111,528 KB |
testcase_44 | AC | 791 ms
98,572 KB |
testcase_45 | AC | 610 ms
93,516 KB |
ソースコード
import sys from itertools import permutations from heapq import * input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N,K,M,P = mi() edge = [[] for v in range(N)] for _ in range(M): u,v = mi() edge[u-1].append(v-1) edge[v-1].append(u-1) S = [int(input()) for i in range(N)] infect = [False] * N immune = [False] * N check = [False] * N for _ in range(K): x = int(input()) infect[x-1] = True event_pq = [] for i in range(N): if infect[i]: heappush(event_pq,(S[i],2,i)) heappush(event_pq,(P,1,i)) while event_pq: t = event_pq[0][0] cure = [] spread = [] while event_pq and event_pq[0][0] == t: _,e,i = heappop(event_pq) if check[i]: continue if e == 1: cure.append(i) else: spread.append(i) #print(t,cure,spread) for i in cure: infect[i] = False immune[i] = True t_check = [] for v in spread: for nv in edge[v]: if check[nv]: continue if not immune[nv]: if not infect[nv]: infect[nv] = True heappush(event_pq,(t+S[nv],2,nv)) heappush(event_pq,(t+P,1,nv)) else: t_check.append(nv) for v in t_check: check[v] = True ans = 0 for i in range(N): ans += int(check[i]) print(ans)