結果

問題 No.2430 Damage Zone
ユーザー tnakao0123tnakao0123
提出日時 2023-08-22 15:27:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,285 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 43,388 KB
実行使用メモリ 10,828 KB
最終ジャッジ日時 2023-08-22 15:27:51
合計ジャッジ時間 2,335 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
10,764 KB
testcase_01 AC 12 ms
10,652 KB
testcase_02 AC 16 ms
10,656 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 4 ms
4,892 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 16 ms
10,656 KB
testcase_15 AC 16 ms
10,764 KB
testcase_16 AC 15 ms
10,660 KB
testcase_17 AC 8 ms
7,496 KB
testcase_18 AC 4 ms
4,912 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 9 ms
7,616 KB
testcase_21 AC 4 ms
4,512 KB
testcase_22 AC 10 ms
10,828 KB
testcase_23 AC 11 ms
10,712 KB
testcase_24 AC 11 ms
10,712 KB
testcase_25 AC 13 ms
10,764 KB
testcase_26 AC 13 ms
10,788 KB
testcase_27 AC 12 ms
10,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2430.cc:  No.2430 Damage Zone - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_H = 100;
const int MAX_W = 100;
const int MAX_K = MAX_H + MAX_W;
const int MOD = 998244353;

/* typedef */

/* global variables */

char fs[MAX_H][MAX_W + 4];
int dp[MAX_H][MAX_W][MAX_K];

/* subroutines */

inline void addmod(int &a, int b) { a = (a + b) % MOD; }

/* main */

int main() {
  int h, w, k;
  scanf("%d%d%d", &h, &w, &k);
  for (int i = 0; i < h; i++) scanf("%s", fs[i]);

  dp[0][0][0] = 1;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      if (fs[i][j] != '#') {
	if (i + 1 < h && fs[i + 1][j] != '#') {
	  if (fs[i + 1][j] == '.')
	    for (int l = 0; l < k; l++)
	      addmod(dp[i + 1][j][l], dp[i][j][l]);
	  else
	    for (int l = 0; l + 1 < k; l++)
	      addmod(dp[i + 1][j][l + 1], dp[i][j][l]);
	}
	if (j + 1 < w && fs[i][j + 1] != '#') {
	  if (fs[i][j + 1] == '.')
	    for (int l = 0; l < k; l++)
	      addmod(dp[i][j + 1][l], dp[i][j][l]);
	  else
	    for (int l = 0; l + 1 < k; l++)
	      addmod(dp[i][j + 1][l + 1], dp[i][j][l]);
	}
      }

  int sum = 0;
  for (int l = 0; l < k; l++)
    addmod(sum, dp[h - 1][w - 1][l]);

  printf("%d\n", sum);
  return 0;
}
0