結果
問題 | No.2430 Damage Zone |
ユーザー |
![]() |
提出日時 | 2024-06-13 01:46:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 19 ms / 2,000 ms |
コード長 | 1,306 bytes |
コンパイル時間 | 2,198 ms |
コンパイル使用メモリ | 206,132 KB |
最終ジャッジ日時 | 2025-02-21 21:28:19 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/modint> using namespace atcoder; using mint = modint998244353; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int h, w, k; cin >> h >> w >> k; vector<string> s(h); for (int i = 0; i < h; i++) { cin >> s[i]; } vector dp(h, vector(w, vector<mint>(k, 0))); dp[0][0][0] = 1; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { for (int l = 0; l < k; l++) { if (j < w - 1 && s[i][j + 1] != '#') { if (s[i][j + 1] == '.') { dp[i][j + 1][l] += dp[i][j][l]; } else if (l < k - 1) { dp[i][j + 1][l + 1] += dp[i][j][l]; } } if (i < h - 1 && s[i + 1][j] != '#') { if (s[i + 1][j] == '.') { dp[i + 1][j][l] += dp[i][j][l]; } else if (l < k - 1) { dp[i + 1][j][l + 1] += dp[i][j][l]; } } } } } mint ans = 0; for (int i = 0; i < k; i++) { ans += dp[h - 1][w - 1][i]; } cout << ans.val() << endl; }