結果
問題 |
No.2528 pop_(backfront or not)
|
ユーザー |
![]() |
提出日時 | 2023-11-03 22:12:51 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,153 ms / 2,000 ms |
コード長 | 765 bytes |
コンパイル時間 | 942 ms |
コンパイル使用メモリ | 94,636 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-25 20:37:46 |
合計ジャッジ時間 | 8,335 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <atcoder/modint> #include <iostream> #include <vector> using namespace std; using mint = atcoder::modint998244353; int main() { int N; cin >> N; vector<mint> dp{1}; while ((int)dp.size() < N * 2 + 1) { vector<mint> dpnxt(dp.size() + 2); for (int i = 0; i < (int)dpnxt.size(); ++i) { if (i and i + 1 < (int)dpnxt.size()) dpnxt.at(i) += dp.at(i - 1); const int l = i - 1, r = (int)dpnxt.size() - 1 - i - 1; if (l > 1) dpnxt.at(i) += dp.at(i - 2) * l * (l - 1) / 2; if (r > 1) dpnxt.at(i) += dp.at(i) * r * (r - 1) / 2; if (l > 0 and r > 0) dpnxt.at(i) += dp.at(i - 1) * l * r; } dp = dpnxt; } for (auto x : dp) cout << x.val() << '\n'; }