結果

問題 No.2430 Damage Zone
ユーザー take000take000
提出日時 2023-08-18 22:03:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 4,665 ms
コンパイル使用メモリ 267,960 KB
実行使用メモリ 11,588 KB
最終ジャッジ日時 2023-08-18 22:03:39
合計ジャッジ時間 6,185 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
7,588 KB
testcase_01 AC 12 ms
6,004 KB
testcase_02 AC 41 ms
11,192 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 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 44 ms
11,540 KB
testcase_15 AC 45 ms
11,532 KB
testcase_16 AC 46 ms
11,588 KB
testcase_17 AC 9 ms
4,692 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 15 ms
6,508 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 3 ms
4,384 KB
testcase_24 AC 3 ms
4,384 KB
testcase_25 AC 9 ms
5,816 KB
testcase_26 AC 13 ms
6,800 KB
testcase_27 AC 8 ms
5,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
using namespace atcoder;
using namespace std;
using mint = modint998244353;

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    rep(i, H) cin >> S[i];

    vector dist(H, vector(W, vector<mint>(K)));
    dist[0][0][0] = 1;

    rep(k, K) rep(i, H) rep(j, W) {
        if (i + 1 < H) {
            if (S[i + 1][j] == '.')
                dist[i + 1][j][k] += dist[i][j][k];
            else if (S[i + 1][j] == 'o' && k + 1 < K)
                dist[i + 1][j][k + 1] += dist[i][j][k];
        }
        if (j + 1 < W) {
            if (S[i][j + 1] == '.')
                dist[i][j + 1][k] += dist[i][j][k];
            else if (S[i][j + 1] == 'o' && k + 1 < K)
                dist[i][j + 1][k + 1] += dist[i][j][k];
        }
    }

    mint ans = 0;
    rep(k, K) ans += dist[H - 1][W - 1][k];
    cout << ans.val() << "\n";

    return 0;
}
0