結果
問題 | No.2528 pop_(backfront or not) |
ユーザー | umimel |
提出日時 | 2023-11-03 23:33:21 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 193 ms / 2,000 ms |
コード長 | 3,479 bytes |
コンパイル時間 | 1,568 ms |
コンパイル使用メモリ | 174,252 KB |
実行使用メモリ | 128,660 KB |
最終ジャッジ日時 | 2023-11-03 23:33:25 |
合計ジャッジ時間 | 3,439 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | 2 ms
4,348 KB |
testcase_07 | AC | 4 ms
5,108 KB |
testcase_08 | AC | 6 ms
6,164 KB |
testcase_09 | AC | 16 ms
12,764 KB |
testcase_10 | AC | 49 ms
33,884 KB |
testcase_11 | AC | 53 ms
36,524 KB |
testcase_12 | AC | 74 ms
51,308 KB |
testcase_13 | AC | 81 ms
56,324 KB |
testcase_14 | AC | 100 ms
68,732 KB |
testcase_15 | AC | 164 ms
105,164 KB |
testcase_16 | AC | 190 ms
128,396 KB |
testcase_17 | AC | 189 ms
128,396 KB |
testcase_18 | AC | 193 ms
128,660 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<ll, ll>; #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); const ll MOD1000000007 = 1000000007; const ll MOD998244353 = 998244353; const ll MOD[3] = {999727999, 1070777777, 1000000007}; const ll LINF = 1LL << 60LL; const int IINF = (1 << 30) - 1; template<long long mod> class modint{ long long x; public: modint(long long x=0) : x((x%mod+mod)%mod) {} modint operator-() const { return modint(-x); } bool operator==(const modint& a){ if(x == a) return true; else return false; } bool operator==(long long a){ if(x == a) return true; else return false; } bool operator!=(const modint& a){ if(x != a) return true; else return false; } bool operator!=(long long a){ if(x != a) return true; else return false; } modint& operator+=(const modint& a) { if ((x += a.x) >= mod) x -= mod; return *this; } modint& operator-=(const modint& a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; } modint& operator*=(const modint& a) { (x *= a.x) %= mod; return *this; } modint operator+(const modint& a) const { modint res(*this); return res+=a; } modint operator-(const modint& a) const { modint res(*this); return res-=a; } modint operator*(const modint& a) const { modint res(*this); return res*=a; } modint pow(long long t) const { if (!t) return 1; modint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime mod modint inv() const { return pow(mod-2); } modint& operator/=(const modint& a) { return (*this) *= a.inv(); } modint operator/(const modint& a) const { modint res(*this); return res/=a; } friend std::istream& operator>>(std::istream& is, modint& m) noexcept { is >> m.x; m.x %= mod; if (m.x < 0) m.x += mod; return is; } friend ostream& operator<<(ostream& os, const modint& m){ os << m.x; return os; } }; using mint = modint<MOD998244353>; void solve(){ ll n; cin >> n; vector<vector<mint>> dp(2*n+2, vector<mint>(2*n+2, 0)); dp[1][1] = 1; mint inv2 = mint(1)/mint(2); for(ll i=3; i<=2*n+1; i+=2){ for(ll j=1; j<=i; j++){ ll lcnt = j-2; ll rcnt = i-(j+1); //左&左 if(2<=lcnt){ dp[i][j] += dp[i-2][j-2]*mint(lcnt)*mint(lcnt-1)*inv2; } //右&右 if(2<=rcnt){ dp[i][j] += dp[i-2][j]*mint(rcnt)*mint(rcnt-1)*inv2; } //左&右 if(1<=lcnt&&1<=rcnt){ dp[i][j] += dp[i-2][j-1]*mint(lcnt)*mint(rcnt); } //最左&最右 if(1<j&&j<i){ dp[i][j] += dp[i-2][j-1]; } } } for(ll j=1; j<=2*n+1; j++) cout << dp[2*n+1][j] << endl; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int T=1; //cin >> T; while(T--) solve(); }