結果
| 問題 | No.2528 pop_(backfront or not) | 
| コンテスト | |
| ユーザー |  arad | 
| 提出日時 | 2023-11-03 21:37:43 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 2,580 bytes | 
| コンパイル時間 | 4,084 ms | 
| コンパイル使用メモリ | 261,136 KB | 
| 最終ジャッジ日時 | 2025-02-17 17:51:46 | 
| ジャッジサーバーID (参考情報) | judge5 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 12 TLE * 2 -- * 5 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using P = pair<ll,ll>;
using VP = vector<P>;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define out(x) cout << x << endl
#define dout(x) cout << fixed << setprecision(10) << x << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)(x.size())
#define re0 return 0
#define pcnt __builtin_popcountll
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int inf = 1e9;
constexpr ll INF = 1e18;
//using mint = modint1000000007;
using mint = modint998244353;
int di[4] = {1,0,-1,0};
int dj[4] = {0,1,0,-1};
// combination mod prime
// https://youtu.be/8uowVvQ_-Mo?t=6002
// https://youtu.be/Tgd_zLfRZOQ?t=9928
struct modinv {
  int n; vector<mint> d;
  modinv(): n(2), d({0,1}) {}
  mint operator()(int i) {
    while (n <= i) d.push_back(-d[mint::mod()%n]*(mint::mod()/n)), ++n;
    return d[i];
  }
  mint operator[](int i) const { return d[i];}
} invs;
struct modfact {
  int n; vector<mint> d;
  modfact(): n(2), d({1,1}) {}
  mint operator()(int i) {
    while (n <= i) d.push_back(d.back()*n), ++n;
    return d[i];
  }
  mint operator[](int i) const { return d[i];}
} facts;
struct modfactinv {
  int n; vector<mint> d;
  modfactinv(): n(2), d({1,1}) {}
  mint operator()(int i) {
    while (n <= i) d.push_back(d.back()*invs(n)), ++n;
    return d[i];
  }
  mint operator[](int i) const { return d[i];}
} ifacts;
mint comb(int n, int k) {
  if (n < k || k < 0) return 0;
  return facts(n)*ifacts(k)*ifacts(n-k);
}
int main(){
    ll n;
    cin >> n;
    map<P,mint> mem;
    auto dp = [&](auto &dp,ll lc,ll rc) -> mint {
        if(mem.count(P(lc,rc))){
            return mem[P(lc,rc)];
        }
        if(lc == 1 && rc == 1) return 1;
        if(lc == 0 || rc == 0) return 0;
        mint res = 0;
        res += dp(dp,lc-1,rc-1);
        if(2 <= lc && 2 <= rc){
            res += dp(dp,lc-1,rc-1)*(lc-1)*(rc-1);
        }
        if(3 <= lc){
            res += dp(dp,lc-2,rc)*comb(lc-1,2);
        }
        if(3 <= rc){
            res += dp(dp,lc,rc-2)*comb(rc-1,2);
        }
        return mem[P(lc,rc)] = res;
    };
    rep(i,2*n+1){
        out(dp(dp,i,2*n-i).val());
    }
}
            
            
            
        