結果

問題 No.2430 Damage Zone
ユーザー aradarad
提出日時 2023-08-19 13:39:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,680 bytes
コンパイル時間 4,686 ms
コンパイル使用メモリ 264,320 KB
実行使用メモリ 11,696 KB
最終ジャッジ日時 2024-05-06 20:47:47
合計ジャッジ時間 5,917 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
11,656 KB
testcase_01 AC 14 ms
11,480 KB
testcase_02 AC 30 ms
11,696 KB
testcase_03 AC 6 ms
11,652 KB
testcase_04 AC 6 ms
11,632 KB
testcase_05 AC 6 ms
11,656 KB
testcase_06 AC 5 ms
11,672 KB
testcase_07 AC 5 ms
11,520 KB
testcase_08 AC 5 ms
11,648 KB
testcase_09 AC 5 ms
11,564 KB
testcase_10 AC 5 ms
11,600 KB
testcase_11 AC 6 ms
11,500 KB
testcase_12 AC 6 ms
11,540 KB
testcase_13 AC 5 ms
11,676 KB
testcase_14 AC 30 ms
11,552 KB
testcase_15 AC 30 ms
11,640 KB
testcase_16 AC 30 ms
11,608 KB
testcase_17 AC 10 ms
11,624 KB
testcase_18 AC 6 ms
11,640 KB
testcase_19 AC 5 ms
11,544 KB
testcase_20 AC 15 ms
11,616 KB
testcase_21 AC 5 ms
11,608 KB
testcase_22 AC 6 ms
11,572 KB
testcase_23 AC 6 ms
11,496 KB
testcase_24 AC 6 ms
11,664 KB
testcase_25 AC 13 ms
11,564 KB
testcase_26 AC 17 ms
11,692 KB
testcase_27 AC 11 ms
11,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using P = pair<ll,ll>;
using VP = vector<P>;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define out(x) cout << x << endl
#define dout(x) cout << fixed << setprecision(10) << x << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)(x.size())
#define re0 return 0
#define pcnt __builtin_popcountll
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int inf = 1e9;
constexpr ll INF = 1e18;
//using mint = modint1000000007;
using mint = modint998244353;
int di[4] = {1,0,-1,0};
int dj[4] = {0,1,0,-1};

mint dp[101][101][202];

int main(){
    int h,w,K;
    cin >> h >> w >> K;
    VS s(h);
    rep(i,h) cin >> s[i];
    rep(i,h)rep(j,w)rep(k,K) dp[i][j][k] = 0;
    dp[0][0][0] = 1;
    rep(i,h)rep(j,w)rep(k,K){
        rep(v,2){
            int ni = i+di[v];
            int nj = j+dj[v];
            if(ni < 0 || nj < 0 || ni >= h || nj >= w) continue;
            if(s[ni][nj] == '#') continue;
            if(s[ni][nj] == 'o' && k+1 < K){
                dp[ni][nj][k+1] += dp[i][j][k];
            }
            if(s[ni][nj] == '.'){
                dp[ni][nj][k] += dp[i][j][k];
            }
        }
    }
    mint ans = 0;
    rep(k,K) ans += dp[h-1][w-1][k];
    out(ans.val());
}
0