結果

問題 No.2430 Damage Zone
ユーザー 👑 獅子座じゃない人獅子座じゃない人
提出日時 2023-08-18 23:11:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,124 bytes
コンパイル時間 1,761 ms
コンパイル使用メモリ 177,244 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-05-06 05:45:46
合計ジャッジ時間 2,859 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
7,680 KB
testcase_01 AC 6 ms
6,144 KB
testcase_02 AC 17 ms
11,136 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 16 ms
11,520 KB
testcase_15 AC 17 ms
11,520 KB
testcase_16 AC 17 ms
11,520 KB
testcase_17 AC 6 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 7 ms
6,656 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 7 ms
6,016 KB
testcase_26 AC 8 ms
6,912 KB
testcase_27 AC 5 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#include <atcoder/modint>
using namespace atcoder;
using mint=modint998244353;

int main(void) {
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for(int i=0;i<h;++i){
        cin >> s[i];
    }
    vector<vector<vector<mint>>> dp(h,vector<vector<mint>>(w,vector<mint>(k+1)));
    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(s[i][j]=='.'){
                    if(i>0){
                        dp[i][j][l]+=dp[i-1][j][l];
                    }
                    if(j>0){
                        dp[i][j][l]+=dp[i][j-1][l];
                    }
                } else if(s[i][j]=='o' && l>0){
                    if(i>0){
                        dp[i][j][l]+=dp[i-1][j][l-1];
                    }
                    if(j>0){
                        dp[i][j][l]+=dp[i][j-1][l-1];
                    }
                }
            }
        }
    }
    mint ans=0;
    for(int l=0;l<=k;++l){
        ans+=dp[h-1][w-1][l];
    }
    cout << ans.val() << endl;
    return 0;
}
0