結果

問題 No.2528 pop_(backfront or not)
ユーザー ococonomy1ococonomy1
提出日時 2023-11-07 10:41:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 1,932 bytes
コンパイル時間 1,248 ms
コンパイル使用メモリ 114,008 KB
実行使用メモリ 128,384 KB
最終ジャッジ日時 2023-11-07 10:41:59
合計ジャッジ時間 3,854 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 5 ms
5,096 KB
testcase_08 AC 7 ms
6,152 KB
testcase_09 AC 18 ms
12,752 KB
testcase_10 AC 55 ms
33,872 KB
testcase_11 AC 60 ms
36,512 KB
testcase_12 AC 85 ms
51,296 KB
testcase_13 AC 94 ms
56,048 KB
testcase_14 AC 115 ms
68,456 KB
testcase_15 AC 180 ms
105,152 KB
testcase_16 AC 242 ms
128,120 KB
testcase_17 AC 216 ms
128,384 KB
testcase_18 AC 216 ms
128,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
// #define AMARI 1000000007
#define TIME_LIMIT 1980000
#define el '\n'
#define El '\n'

#define MULTI_TEST_CASE false
void solve(void) {
    int n;
    cin >> n;
    //dp[i][j] := ある値について、左からi個、右からj個取るのが何通りあるか
    vector<vector<ll>> dp(2 * n + 1,vector<ll>(2 * n + 1));
    dp[0][0] = 1;
    for(int i = 0; i < 2 * n + 1; i++){
        for(int j = 0; j < 2 * n + 1; j++){
            if(i == 0 && j == 0)continue;
            if(i >= 1 && j >= 1){
                //外側(1) + 内側((i-1)*(j-1))
                dp[i][j] += dp[i - 1][j - 1] *(ll)((i - 1) * (j - 1) + 1);
                dp[i][j] %= AMARI;
            }
            if(i >= 2){
                dp[i][j] += dp[i - 2][j] * (ll)((i - 2) * (i - 1) / 2);
                dp[i][j] %= AMARI;
            }
            if(j >= 2){
                dp[i][j] += dp[i][j - 2] * (ll)((j - 2) * (j - 1) / 2);
                dp[i][j] %= AMARI;
            }
        }
    }
    for(int i = 0; i < 2 * n + 1; i++){
        //cerr << i << ' ' << 2 * n - i << el;
        cout << dp[i][2 * n - i] << el;
    }
    return;
}

void calc(void) {
    return;
}

//WTFday1A
//ABC227D
//ABC325G
//ABC191F
//ARC110C

signed main(void) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    calc();
    int t = 1;
    if(MULTI_TEST_CASE) cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}
0