結果

問題 No.3213 depth max K
ユーザー detteiuu
提出日時 2025-07-25 22:05:21
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 3,271 ms
コンパイル使用メモリ 280,436 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-07-25 22:05:28
合計ジャッジ時間 5,519 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using mint = modint998244353;

mint DP(int limit, int N) {
    vector<mint> dp(limit+1, 0);
    dp[0] = 1;
    for (int i=0; i<N*2; i++) {
        vector<mint> ndp(limit+1, 0);
        for (int j=0; j<=limit; j++) {
            if (1 <= j) {
                ndp[j-1] += dp[j];
            }
            if (j+1 <= limit) {
                ndp[j+1] += dp[j];
            }
        }
        dp = ndp;
    }
    return dp[0];
}

int main() {
    int N, K;
    cin >> N >> K;

    cout << (DP(K, N)-DP(K-1, N)).val() << endl;
    return 0;
}
0