結果

問題 No.2528 pop_(backfront or not)
ユーザー GOTKAKOGOTKAKO
提出日時 2023-11-03 22:46:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 358 ms / 2,000 ms
コード長 920 bytes
コンパイル時間 2,414 ms
コンパイル使用メモリ 207,148 KB
実行使用メモリ 128,324 KB
最終ジャッジ日時 2023-11-03 22:46:26
合計ジャッジ時間 4,832 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 1 ms
4,372 KB
testcase_05 AC 3 ms
4,372 KB
testcase_06 AC 4 ms
4,372 KB
testcase_07 AC 7 ms
5,036 KB
testcase_08 AC 9 ms
6,092 KB
testcase_09 AC 27 ms
12,692 KB
testcase_10 AC 83 ms
33,812 KB
testcase_11 AC 104 ms
36,452 KB
testcase_12 AC 132 ms
51,236 KB
testcase_13 AC 143 ms
55,988 KB
testcase_14 AC 177 ms
68,396 KB
testcase_15 AC 277 ms
105,092 KB
testcase_16 AC 337 ms
128,060 KB
testcase_17 AC 358 ms
128,324 KB
testcase_18 AC 342 ms
128,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

long long mod = 998244353;
long long nC2(long long n){
    return n*(n-1)/2%mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    vector<vector<long long>> dp(2*N+1,vector<long long>(2*N+1));
    dp.at(0).at(0) = 1;
    for(int i=0; i<2*N; i+=2){
        for(int k=0; k<=2*N; k++){
            long long d = dp.at(i).at(k);
            if(d == 0) continue;
            
            long long l = k,r = i-k;
            dp.at(i+2).at(k+1) = (dp.at(i+2).at(k+1)+d)%mod;

            long long now = 0;
            now = nC2(l-1+2);
            dp.at(i+2).at(l+2) = (dp.at(i+2).at(l+2)+now*d)%mod;
            now = nC2(r-1+2);
            dp.at(i+2).at(l) = (dp.at(i+2).at(l)+now*d)%mod;
            dp.at(i+2).at(k+1) = (dp.at(i+2).at(k+1)+d*l*r)%mod;
        }
    }

    for(auto ans : dp.at(2*N)) cout << ans << endl;
}
0