結果

問題 No.2528 pop_(backfront or not)
ユーザー SSRSSSRS
提出日時 2023-10-20 03:24:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 2,263 ms
コンパイル使用メモリ 205,660 KB
実行使用メモリ 34,992 KB
最終ジャッジ日時 2023-10-20 03:24:31
合計ジャッジ時間 3,548 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 4 ms
4,364 KB
testcase_09 AC 7 ms
6,004 KB
testcase_10 AC 19 ms
11,336 KB
testcase_11 AC 20 ms
11,956 KB
testcase_12 AC 27 ms
15,664 KB
testcase_13 AC 29 ms
16,892 KB
testcase_14 AC 35 ms
20,008 KB
testcase_15 AC 52 ms
29,132 KB
testcase_16 AC 61 ms
34,932 KB
testcase_17 AC 61 ms
34,964 KB
testcase_18 AC 61 ms
34,992 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 + 1);
  for (int i = 0; i <= N; i++){
    dp[i] = vector<long long>(i * 2 + 1, 0);
  }
  dp[0][0] = 1;
  for (int i = 1; i <= N; i++){
    for (int j = 1; j < i * 2; j++){
      dp[i][j] = dp[i - 1][j - 1];
      if (j >= 3){
        dp[i][j] += dp[i - 1][j - 2] * (j - 1) * (j - 2) / 2;
        dp[i][j] %= MOD;
      }
      dp[i][j] += dp[i - 1][j - 1] * (j - 1) * (i * 2 - 1 - j);
      dp[i][j] %= MOD;
      if (j < i * 2 - 2){
        dp[i][j] += dp[i - 1][j] * (i * 2 - 1 - j) * (i * 2 - 2 - j) / 2;
        dp[i][j] %= MOD;
      }
    }
  }
  for (int i = 0; i <= N * 2; i++){
    cout << dp[N][i] << endl;
  }
}
0