結果
問題 | No.2528 pop_(backfront or not) |
ユーザー | shobonvip |
提出日時 | 2023-11-03 21:54:44 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 284 ms / 2,000 ms |
コード長 | 1,918 bytes |
コンパイル時間 | 4,350 ms |
コンパイル使用メモリ | 266,772 KB |
実行使用メモリ | 73,904 KB |
最終ジャッジ日時 | 2023-11-03 21:54:52 |
合計ジャッジ時間 | 7,166 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 12 ms
11,484 KB |
testcase_01 | AC | 12 ms
11,488 KB |
testcase_02 | AC | 11 ms
11,488 KB |
testcase_03 | AC | 11 ms
11,488 KB |
testcase_04 | AC | 12 ms
11,488 KB |
testcase_05 | AC | 12 ms
11,652 KB |
testcase_06 | AC | 13 ms
11,796 KB |
testcase_07 | AC | 15 ms
12,436 KB |
testcase_08 | AC | 17 ms
12,916 KB |
testcase_09 | AC | 29 ms
15,824 KB |
testcase_10 | AC | 71 ms
26,648 KB |
testcase_11 | AC | 76 ms
27,704 KB |
testcase_12 | AC | 103 ms
35,096 KB |
testcase_13 | AC | 117 ms
37,736 KB |
testcase_14 | AC | 138 ms
43,808 KB |
testcase_15 | AC | 204 ms
62,024 KB |
testcase_16 | AC | 252 ms
73,640 KB |
testcase_17 | AC | 284 ms
73,904 KB |
testcase_18 | AC | 251 ms
73,904 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; //* ATCODER #include<atcoder/all> using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include<boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template <typename T> bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template <typename T> bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template <typename T> T max(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template <typename T> T min(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template <typename T> T sum(vector<T> &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } //defmodfact const int COMinitMAX = 998244; mint fact[COMinitMAX+1], factinv[COMinitMAX+1]; void modfact(){ fact[0] = 1; for (int i=1; i<=COMinitMAX; i++){ fact[i] = fact[i-1] * i; } factinv[COMinitMAX] = fact[COMinitMAX].inv(); for (int i=COMinitMAX-1; i>=0; i--){ factinv[i] = factinv[i+1] * (i+1); } } mint cmb(int a, int b){ if (a<b || b<0) return mint(0); return fact[a]*factinv[b]*factinv[a-b]; } //-------- int main(){ modfact(); int n; cin >> n; vector dp(2*n+1, vector<mint>(2*n+1)); dp[0][0] = 1; rep(i,1,2*n+1){ rep(j,1,2*n+1){ dp[i][j] += dp[i-1][j-1]; if (i-2 >= 1){ dp[i][j] += dp[i-2][j] * cmb(i-1, 2); } if (j-2 >= 1){ dp[i][j] += dp[i][j-2] * cmb(j-1, 2); } if (i-1 >= 1 && j-1 >= 1){ dp[i][j] += dp[i-1][j-1] * mint(i-1) * mint(j-1); } } } rep(i,0,2*n+1){ cout << dp[i][2*n-i].val() << '\n'; } }