結果

問題 No.2430 Damage Zone
ユーザー miho-4miho-4
提出日時 2023-08-18 22:31:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 926 ms / 2,000 ms
コード長 724 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 189,556 KB
最終ジャッジ日時 2023-08-18 22:32:03
合計ジャッジ時間 10,821 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 652 ms
139,936 KB
testcase_01 AC 240 ms
86,560 KB
testcase_02 AC 918 ms
189,336 KB
testcase_03 AC 112 ms
76,804 KB
testcase_04 AC 130 ms
78,244 KB
testcase_05 AC 134 ms
78,564 KB
testcase_06 AC 96 ms
71,640 KB
testcase_07 AC 97 ms
71,692 KB
testcase_08 AC 97 ms
71,696 KB
testcase_09 AC 98 ms
71,416 KB
testcase_10 AC 96 ms
71,416 KB
testcase_11 AC 150 ms
79,612 KB
testcase_12 AC 145 ms
79,500 KB
testcase_13 AC 97 ms
71,556 KB
testcase_14 AC 926 ms
186,032 KB
testcase_15 AC 915 ms
189,556 KB
testcase_16 AC 901 ms
187,672 KB
testcase_17 AC 449 ms
120,548 KB
testcase_18 AC 227 ms
85,436 KB
testcase_19 AC 99 ms
75,784 KB
testcase_20 AC 433 ms
116,080 KB
testcase_21 AC 164 ms
79,672 KB
testcase_22 AC 156 ms
80,112 KB
testcase_23 AC 158 ms
80,468 KB
testcase_24 AC 161 ms
79,896 KB
testcase_25 AC 338 ms
105,236 KB
testcase_26 AC 341 ms
104,712 KB
testcase_27 AC 320 ms
101,296 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