結果

問題 No.2528 pop_(backfront or not)
ユーザー SSRSSSRS
提出日時 2023-10-20 03:42:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 717 bytes
コンパイル時間 2,297 ms
コンパイル使用メモリ 206,548 KB
実行使用メモリ 128,488 KB
最終ジャッジ日時 2023-10-20 03:42:15
合計ジャッジ時間 4,312 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,572 KB
testcase_08 AC 7 ms
6,256 KB
testcase_09 AC 16 ms
12,856 KB
testcase_10 AC 47 ms
33,976 KB
testcase_11 AC 52 ms
36,616 KB
testcase_12 AC 72 ms
51,400 KB
testcase_13 AC 79 ms
56,152 KB
testcase_14 AC 95 ms
68,560 KB
testcase_15 AC 147 ms
105,256 KB
testcase_16 AC 180 ms
128,224 KB
testcase_17 AC 177 ms
128,488 KB
testcase_18 AC 177 ms
128,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
int main(){
  int N;
  cin >> N;
  vector<vector<long long>> dp(N * 2 + 1, vector<long long>(N * 2 + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i <= N * 2; i++){
    for (int j = 0; j <= N * 2 - i; j++){
      if (i >= 2){
        dp[i][j] += dp[i - 2][j] * (i - 1) * (i - 2) / 2;
        dp[i][j] %= MOD;
      }
      if (j >= 2){
        dp[i][j] += dp[i][j - 2] * (j - 1) * (j - 2) / 2;
        dp[i][j] %= MOD;
      }
      if (i >= 1 && j >= 1){
        dp[i][j] += dp[i - 1][j - 1] * ((i - 1) * (j - 1) + 1);
        dp[i][j] %= MOD;
      }
    }
  }
  for (int i = 0; i <= N * 2; i++){
    cout << dp[i][N * 2 - i] << endl;
  }
}
0