結果
問題 | No.2430 Damage Zone |
ユーザー |
![]() |
提出日時 | 2023-08-27 00:30:47 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 1,286 bytes |
コンパイル時間 | 6,748 ms |
コンパイル使用メモリ | 140,920 KB |
実行使用メモリ | 19,328 KB |
最終ジャッジ日時 | 2024-12-26 04:43:27 |
合計ジャッジ時間 | 5,240 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <cassert> #include <cmath> #include <algorithm> #include <iostream> #include <iomanip> #include <climits> #include <map> #include <queue> #include <set> #include <cstring> #include <vector> using namespace std; typedef long long ll; const ll MOD = 998244353; ll dp[101][101][201]; int main() { int H, W, K; cin >> H >> W >> K; vector<string> S(H); for (int i = 0; i < H; ++i) { cin >> S[i]; } dp[0][0][K] = 1; for (int y = 0; y < H; ++y) { for (int x = 0; x < W; ++x) { for (int k = 1; k <= K; ++k) { if (y + 1 < H && S[y + 1][x] != '#') { if (S[y + 1][x] == 'o') { dp[y + 1][x][k - 1] += dp[y][x][k]; dp[y + 1][x][k - 1] %= MOD; } else { dp[y + 1][x][k] += dp[y][x][k]; dp[y + 1][x][k] %= MOD; } } if (x + 1 < W && S[y][x + 1] != '#') { if (S[y][x + 1] == 'o') { dp[y][x + 1][k - 1] += dp[y][x][k]; dp[y][x + 1][k - 1] %= MOD; } else { dp[y][x + 1][k] += dp[y][x][k]; dp[y][x + 1][k] %= MOD; } } } } } ll ans = 0; for (int k = 1; k <= K; ++k) { ans += dp[H - 1][W - 1][k]; ans %= MOD; } cout << ans << endl; return 0; }