結果

問題 No.2430 Damage Zone
ユーザー kuronikuroni
提出日時 2023-08-18 22:05:47
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,000 bytes
コンパイル時間 3,769 ms
コンパイル使用メモリ 255,112 KB
実行使用メモリ 11,496 KB
最終ジャッジ日時 2023-08-18 22:05:53
合計ジャッジ時間 5,068 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
7,536 KB
testcase_01 AC 7 ms
5,928 KB
testcase_02 AC 19 ms
11,000 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 21 ms
11,492 KB
testcase_15 AC 20 ms
11,496 KB
testcase_16 AC 20 ms
11,496 KB
testcase_17 AC 6 ms
4,904 KB
testcase_18 AC 3 ms
4,384 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 9 ms
6,444 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 8 ms
5,808 KB
testcase_26 AC 10 ms
6,772 KB
testcase_27 AC 6 ms
5,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;

using mint = modint998244353;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int m, n, h; cin >> m >> n >> h;
    vector<string> s(m);
    for (int i = 0; i < m; i++) {
        cin >> s[i];
    }
    vector dp(m, vector(n, vector<mint>(h + 1)));
    dp[0][0][h] = 1;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            if (s[i][j] == '#') {
                continue;
            }
            for (int k = 1; k <= h; k++) {
                if (i > 0 && (k < h || s[i][j] == '.')) {
                    dp[i][j][k] += dp[i - 1][j][k + (s[i][j] == 'o')];
                }
                if (j > 0 && (k < h || s[i][j] == '.')) {
                    dp[i][j][k] += dp[i][j - 1][k + (s[i][j] == 'o')];
                }
            }
        }
    }
    cout << accumulate(dp[m - 1][n - 1].begin(), dp[m - 1][n - 1].end(), mint(0)).val();
}
0