結果

問題 No.2430 Damage Zone
ユーザー noya2noya2
提出日時 2023-08-13 02:00:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 812 bytes
コンパイル時間 2,526 ms
コンパイル使用メモリ 212,996 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2024-04-30 20:33:43
合計ジャッジ時間 3,731 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
7,808 KB
testcase_01 AC 8 ms
6,944 KB
testcase_02 AC 18 ms
11,264 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 19 ms
11,648 KB
testcase_15 AC 20 ms
11,648 KB
testcase_16 AC 20 ms
11,776 KB
testcase_17 AC 5 ms
6,944 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 10 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 3 ms
6,944 KB
testcase_24 AC 3 ms
6,940 KB
testcase_25 AC 8 ms
6,944 KB
testcase_26 AC 10 ms
7,168 KB
testcase_27 AC 7 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int h, w, k; cin >> h >> w >> k;
    vector<string> a(h);
    for (int i = 0; i < h; i++) cin >> a[i];
    vector dp(h+1,vector(w+1,vector<mint>(k+1,0)));
    dp[0][0][0] = 1;
    for (int x = 0; x < h; x++) for (int y = 0; y < w; y++) for (int i = 0; i < k; i++){
        if (x != h-1 && a[x+1][y] != '#'){
            int j = i + (a[x+1][y] == 'o' ? 1 : 0);
            dp[x+1][y][j] += dp[x][y][i];
        }
        if (y != w-1 && a[x][y+1] != '#'){
            int j = i + (a[x][y+1] == 'o' ? 1 : 0);
            dp[x][y+1][j] += dp[x][y][i];
        }
    }
    mint ans = 0;
    for (int i = 0; i < k; i++){
        ans += dp[h-1][w-1][i];
    }
    cout << ans.val() << endl;
}
0