結果

問題 No.2430 Damage Zone
ユーザー miho-4miho-4
提出日時 2023-08-18 22:31:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 768 ms / 2,000 ms
コード長 724 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 188,016 KB
最終ジャッジ日時 2024-05-06 04:50:52
合計ジャッジ時間 7,953 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 493 ms
137,524 KB
testcase_01 AC 177 ms
85,620 KB
testcase_02 AC 740 ms
187,104 KB
testcase_03 AC 51 ms
65,408 KB
testcase_04 AC 66 ms
74,496 KB
testcase_05 AC 77 ms
77,312 KB
testcase_06 AC 39 ms
54,016 KB
testcase_07 AC 38 ms
53,888 KB
testcase_08 AC 39 ms
53,760 KB
testcase_09 AC 39 ms
53,632 KB
testcase_10 AC 40 ms
53,888 KB
testcase_11 AC 92 ms
78,188 KB
testcase_12 AC 87 ms
77,696 KB
testcase_13 AC 40 ms
53,504 KB
testcase_14 AC 729 ms
185,900 KB
testcase_15 AC 768 ms
188,016 KB
testcase_16 AC 752 ms
185,700 KB
testcase_17 AC 377 ms
120,028 KB
testcase_18 AC 142 ms
84,748 KB
testcase_19 AC 42 ms
58,752 KB
testcase_20 AC 357 ms
113,380 KB
testcase_21 AC 101 ms
79,180 KB
testcase_22 AC 98 ms
78,356 KB
testcase_23 AC 98 ms
78,316 KB
testcase_24 AC 99 ms
78,484 KB
testcase_25 AC 275 ms
102,640 KB
testcase_26 AC 282 ms
102,728 KB
testcase_27 AC 250 ms
98,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353
from collections import deque,defaultdict
H,W,K=map(int,input().split())
L=[input() for _ in range(H)]
flag=[[1]*W for _ in range(H)]
D=defaultdict(set)#key=(h,w,d)
D[(0,0)]={0}
D2=defaultdict(int)
D2[(0,0,0)]=1
ans=0
q=deque([(0,0)])
while q:
  h,w=q.popleft()
  for dh,dw in [(1,0),(0,1)]:
    if h+dh<H and w+dw<W and L[h+dh][w+dw]!="#":
      if flag[h+dh][w+dw]:
        q.append((h+dh,w+dw))
        flag[h+dh][w+dw]=0
      dd=0
      if L[h+dh][w+dw]=="o":dd=1
      for d in D[(h,w)]:
        if d+dd<K:
          D[(h+dh,w+dw)].add(d+dd)
          D2[((h+dh,w+dw,d+dd))]+=D2[(h,w,d)]
          D2[((h+dh,w+dw,d+dd))]%=mod
ans=0
for d in D[(H-1,W-1)]:
  ans+=D2[(H-1,W-1,d)]
  ans%=mod
print(ans)

  
0