結果

問題 No.2430 Damage Zone
ユーザー tomeruntomerun
提出日時 2023-08-18 22:53:33
言語 Crystal
(1.11.2)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 889 bytes
コンパイル時間 13,395 ms
コンパイル使用メモリ 296,024 KB
実行使用メモリ 25,088 KB
最終ジャッジ日時 2024-05-06 05:22:32
合計ジャッジ時間 14,973 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
14,208 KB
testcase_01 AC 18 ms
8,704 KB
testcase_02 AC 52 ms
24,960 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 58 ms
25,088 KB
testcase_15 AC 57 ms
24,960 KB
testcase_16 AC 57 ms
24,960 KB
testcase_17 AC 12 ms
6,400 KB
testcase_18 AC 5 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 23 ms
11,136 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 19 ms
8,064 KB
testcase_26 AC 30 ms
14,080 KB
testcase_27 AC 15 ms
6,912 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