結果
問題 | No.2528 pop_(backfront or not) |
ユーザー | lemondo |
提出日時 | 2023-11-03 22:50:38 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 7,386 bytes |
コンパイル時間 | 3,346 ms |
コンパイル使用メモリ | 304,796 KB |
実行使用メモリ | 128,768 KB |
最終ジャッジ日時 | 2024-09-25 21:13:45 |
合計ジャッジ時間 | 8,352 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
34,688 KB |
testcase_01 | AC | 30 ms
34,688 KB |
testcase_02 | AC | 30 ms
34,688 KB |
testcase_03 | AC | 29 ms
34,560 KB |
testcase_04 | AC | 29 ms
34,688 KB |
testcase_05 | AC | 31 ms
34,944 KB |
testcase_06 | AC | 33 ms
35,200 KB |
testcase_07 | AC | 42 ms
36,608 KB |
testcase_08 | AC | 48 ms
37,632 KB |
testcase_09 | AC | 89 ms
44,032 KB |
testcase_10 | AC | 228 ms
65,536 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
ソースコード
#pragma region Macros #include <bits/stdc++.h> #include <immintrin.h> #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cctype> #include <cfenv> #include <cfloat> #include <chrono> #include <cinttypes> #include <climits> #include <cmath> #include <complex> #include <cstdarg> #include <cstddef> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <initializer_list> #include <iomanip> #include <ios> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <streambuf> #include <string> #include <tuple> #include <type_traits> #include <typeinfo> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define ll long long #define OVERLOAD(e1, e2, e3, e4, NAME, ...) NAME #define _rep1(i, n) for (long long i = 0; i < n; i++) #define _rep2(i, a, b) for (long long i = a; i < b; ++i) #define _rep3(i, a, b, t) \ for (long long i = a; i * (t / abs(t)) < b * (t / abs(t)); i += t) #define rep(...) OVERLOAD(__VA_ARGS__, _rep3, _rep2, _rep1, _)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define sz(x) (int)x.size() #define fi first #define se second #define pb push_back #define eb emplace_back #define mp make_pair #define pcnt __builtin_popcountll #define SORT(v) sort(all(v)) #define UNIQUE(v) \ SORT(v); \ v.erase(unique(v.begin(), v.end()), v.end()); #define COPY(A, B) copy(all(A), B.begin()); #define REV(v) reverse(all(v)) #define MAX(x) *max_element(all(x)) #define MIN(x) *min_element(all(x)) #ifdef LOCAL #define dbg(x) \ { \ cout << __LINE__ << " : " << #x << " = "; \ print(x); \ } #define IS_LOCAL true #else #define dbg(x) true #define IS_LOCAL false #endif using namespace std; template <typename T> using vc = vector<T>; template <typename T> using vvc = vector<vc<T>>; template <typename T> using vvvc = vector<vvc<T>>; template <typename T> bool chmin(T &k, T m) { bool ret = k > m; k = min(k, m); return ret; } template <typename T> bool chmax(T &k, T m) { bool ret = k < m; k = max(k, m); return ret; } template <typename T> inline void print(const vector<T> &v, string s = " ") { for (int i = 0; i < (int)v.size(); i++) cout << v[i] << (i != (int)v.size() - 1 ? s : ""); cout << "\n"; } template <typename T, typename S> inline void print(const pair<T, S> &p) { cout << p.first << " " << p.second << endl; } template <typename T> inline void print(const T &x) { cout << x << "\n"; } template <typename T, typename S> inline void print(const vector<pair<T, S>> &v) { for (auto &&p : v) print(p); } void yes(bool a) { cout << (a ? "yes" : "no") << endl; } void YES(bool a) { cout << (a ? "YES" : "NO") << endl; } void Yes(bool a) { cout << (a ? "Yes" : "No") << endl; } template <typename T> T SUM(vc<T> As) { T ret = 0; for (T a : As) ret += a; return ret; } #pragma endregion const ll INF = numeric_limits<long long>::max(); template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while (b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while (n > 0) { if (n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt<mod>(t); return (is); } static int get_mod() { return mod; } int val() const { return x; } }; const int mod = 998244353; using mint = ModInt<mod>; template <typename T> struct Combination { vector<T> _fact, _rfact, _inv; Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) { _fact[0] = _rfact[sz] = _inv[0] = 1; for (int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i; _rfact[sz] /= _fact[sz]; for (int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1); for (int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1]; } inline T fact(int k) const { return _fact[k]; } inline T rfact(int k) const { return _rfact[k]; } inline T inv(int k) const { return _inv[k]; } T P(int n, int r) const { if (r < 0 || n < r) return 0; return fact(n) * rfact(n - r); } T C(int p, int q) const { if (q < 0 || p < q) return 0; return fact(p) * rfact(q) * rfact(p - q); } T H(int n, int r) const { if (n < 0 || r < 0) return (0); return r == 0 ? 1 : C(n + r - 1, r); } }; void solve() { ll N; cin >> N; ll base = 2001; unordered_map<ll, mint> memo(2001 * 2002); Combination<mint> comb(4000); auto dfs = [&](auto self, ll l, ll r) -> mint { if (memo.count(l * base + r)) return memo[l * base + r]; if (l == 0 && r == 0) return mint(1); mint ret = 0; if (l > 0 && r > 0) { // 両端を取る ret += self(self, l - 1, r - 1); } if (l > 1 && r > 1) { // 両端以外を1個ずつ ret += self(self, l - 1, r - 1) * (l - 1) * (r - 1); } if (l > 2) { ret += self(self, l - 2, r) * comb.C(l - 1, 2); } if (r > 2) { ret += self(self, l, r - 2) * comb.C(r - 1, 2); } memo[l * base + r] = ret; return ret; }; rep(i, 1, N * 2 + 2) { if (i == 1 || i == N * 2 + 1) { print(0); continue; } print(dfs(dfs, i - 1, N * 2 + 1 - i)); } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); // ll T; cin >> T; // rep(_, T) solve(); }