結果

問題 No.2430 Damage Zone
ユーザー achapiachapi
提出日時 2023-08-18 22:11:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 903 bytes
コンパイル時間 4,873 ms
コンパイル使用メモリ 269,036 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2024-05-06 04:18:57
合計ジャッジ時間 5,131 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,680 KB
testcase_01 AC 10 ms
6,016 KB
testcase_02 AC 30 ms
11,008 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 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 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 33 ms
11,776 KB
testcase_15 AC 31 ms
11,520 KB
testcase_16 AC 31 ms
11,648 KB
testcase_17 AC 8 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 13 ms
6,656 KB
testcase_21 AC 3 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 10 ms
6,016 KB
testcase_26 AC 14 ms
6,912 KB
testcase_27 AC 8 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::modint998244353;
using namespace std;

int dx[2] = {1, 0};
int dy[2] = {0, 1};

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> S(H);
	for (int i = 0; i < H; i++){
		cin >> S[i];
	}
	vector<vector<vector<mint>>> dp(H, vector<vector<mint>>(W, vector<mint>(K + 1)));
	dp[0][0][K] = 1;
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			for (int k = 1; k <= K; k++){
				for (int l = 0; l < 2; l++){
					int px = i + dx[l], py = j + dy[l];
					if (0 <= px and px < H and 0 <= py and py < W and S[px][py] != '#'){
						if (S[px][py] == '.'){
							dp[px][py][k] += dp[i][j][k];
						} else {
							if (k > 1){
								dp[px][py][k - 1] += dp[i][j][k];
							}
						}
					}
				}
			}
		}
	}
	mint ans = 0;
	for (int i = 1; i <= K; i++){
		ans += dp[H - 1][W - 1][i];
	}
	cout << ans.val() << '\n';
}
0