結果

問題 No.2430 Damage Zone
ユーザー laneguelanegue
提出日時 2023-08-18 23:28:05
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,169 bytes
コンパイル時間 5,410 ms
コンパイル使用メモリ 161,952 KB
実行使用メモリ 25,236 KB
最終ジャッジ日時 2023-08-18 23:28:14
合計ジャッジ時間 4,511 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
14,220 KB
testcase_01 AC 9 ms
9,048 KB
testcase_02 AC 26 ms
25,236 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 27 ms
25,212 KB
testcase_15 AC 27 ms
24,924 KB
testcase_16 AC 28 ms
24,956 KB
testcase_17 AC 7 ms
7,992 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 14 ms
12,120 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 11 ms
9,004 KB
testcase_26 AC 15 ms
12,448 KB
testcase_27 AC 7 ms
7,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;
const ulong MOD = 998244353;
void main(){
  auto input = readln.chomp.split.to!(int[]);
  int h = input[0];
  int w = input[1];
  int k = input[2];
  string[] s;
  for(auto i = 0; i < h; i++){
    s ~= readln.chomp;
  }
  auto dp = new ulong[][][](h, w, k);
  dp[0][0][0] = 1;
  for(auto i = 0; i < h; i++){
    for(auto j = 0; j < w; j++){
      for(auto d = 0; d < k; d++){
        dp[i][j][d] %= MOD;
        if(i < h - 1){
          switch(s[i + 1][j]){
            case '.':
              dp[i + 1][j][d] += dp[i][j][d];
              break;
            case 'o':
              if(d < k - 1){
                dp[i + 1][j][d + 1] += dp[i][j][d];
              }
              break;
            default:
              break;
          }
        }
        if(j < w - 1){
          switch(s[i][j + 1]){
            case '.':
              dp[i][j + 1][d] += dp[i][j][d];
              break;
            case 'o':
              if(d < k - 1){
                dp[i][j + 1][d + 1] += dp[i][j][d];
              }
              break;
            default:
              break;
          }
        }
      }
    }
  }
  writeln(dp[$ - 1][$ - 1].sum % MOD);
}
0