結果

問題 No.2430 Damage Zone
ユーザー tomeruntomerun
提出日時 2023-08-18 22:53:33
言語 Crystal
(1.11.2)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 889 bytes
コンパイル時間 24,002 ms
コンパイル使用メモリ 256,340 KB
実行使用メモリ 27,664 KB
最終ジャッジ日時 2023-08-18 22:54:03
合計ジャッジ時間 26,107 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
15,840 KB
testcase_01 AC 20 ms
10,212 KB
testcase_02 AC 60 ms
27,656 KB
testcase_03 AC 4 ms
4,744 KB
testcase_04 AC 5 ms
5,052 KB
testcase_05 AC 6 ms
5,048 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,480 KB
testcase_08 AC 3 ms
4,424 KB
testcase_09 AC 3 ms
4,516 KB
testcase_10 AC 3 ms
4,416 KB
testcase_11 AC 4 ms
4,924 KB
testcase_12 AC 5 ms
4,936 KB
testcase_13 AC 3 ms
4,484 KB
testcase_14 AC 62 ms
27,024 KB
testcase_15 AC 62 ms
27,664 KB
testcase_16 AC 61 ms
27,224 KB
testcase_17 AC 14 ms
8,184 KB
testcase_18 AC 5 ms
5,300 KB
testcase_19 AC 3 ms
4,460 KB
testcase_20 AC 26 ms
12,812 KB
testcase_21 AC 4 ms
4,628 KB
testcase_22 AC 4 ms
5,132 KB
testcase_23 AC 4 ms
5,136 KB
testcase_24 AC 4 ms
5,132 KB
testcase_25 AC 21 ms
9,696 KB
testcase_26 AC 34 ms
15,652 KB
testcase_27 AC 16 ms
8,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
h, w, k = read_line.split.map(&.to_i)
s = Array.new(h) { read_line.chars }
dp = Array.new(h) { Array.new(w) { Array.new(k, 0i64) } }
dp[0][0][0] = 1
h.times do |i|
  w.times do |j|
    next if s[i][j] == '#'
    k.times do |l|
      if i != h - 1
        case s[i + 1][j]
        when 'o'
          if l < k - 1
            dp[i + 1][j][l + 1] += dp[i][j][l]
            dp[i + 1][j][l + 1] %= MOD
          end
        when '.'
          dp[i + 1][j][l] += dp[i][j][l]
          dp[i + 1][j][l] %= MOD
        end
      end
      if j != w - 1
        case s[i][j + 1]
        when 'o'
          if l < k - 1
            dp[i][j + 1][l + 1] += dp[i][j][l]
            dp[i][j + 1][l + 1] %= MOD
          end
        when '.'
          dp[i][j + 1][l] += dp[i][j][l]
          dp[i][j + 1][l] %= MOD
        end
      end
    end
  end
end
puts dp[h - 1][w - 1].sum % MOD
0