結果
問題 | No.2966 Simple Plus Minus Problem |
ユーザー | KumaTachiRen |
提出日時 | 2024-11-16 16:31:21 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 159 ms / 2,567 ms |
コード長 | 5,064 bytes |
コンパイル時間 | 6,420 ms |
コンパイル使用メモリ | 321,996 KB |
実行使用メモリ | 18,900 KB |
最終ジャッジ日時 | 2024-11-16 16:31:46 |
合計ジャッジ時間 | 13,410 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
5,248 KB |
testcase_01 | AC | 4 ms
5,248 KB |
testcase_02 | AC | 4 ms
5,248 KB |
testcase_03 | AC | 106 ms
12,744 KB |
testcase_04 | AC | 150 ms
18,512 KB |
testcase_05 | AC | 4 ms
5,248 KB |
testcase_06 | AC | 4 ms
5,248 KB |
testcase_07 | AC | 7 ms
5,248 KB |
testcase_08 | AC | 5 ms
5,248 KB |
testcase_09 | AC | 6 ms
5,248 KB |
testcase_10 | AC | 4 ms
5,248 KB |
testcase_11 | AC | 6 ms
5,248 KB |
testcase_12 | AC | 5 ms
5,248 KB |
testcase_13 | AC | 6 ms
5,248 KB |
testcase_14 | AC | 4 ms
5,248 KB |
testcase_15 | AC | 4 ms
5,248 KB |
testcase_16 | AC | 4 ms
5,248 KB |
testcase_17 | AC | 7 ms
5,248 KB |
testcase_18 | AC | 4 ms
5,248 KB |
testcase_19 | AC | 5 ms
5,248 KB |
testcase_20 | AC | 6 ms
5,248 KB |
testcase_21 | AC | 4 ms
5,248 KB |
testcase_22 | AC | 4 ms
5,248 KB |
testcase_23 | AC | 5 ms
5,248 KB |
testcase_24 | AC | 10 ms
5,248 KB |
testcase_25 | AC | 8 ms
5,248 KB |
testcase_26 | AC | 5 ms
5,248 KB |
testcase_27 | AC | 10 ms
5,248 KB |
testcase_28 | AC | 5 ms
5,248 KB |
testcase_29 | AC | 9 ms
5,248 KB |
testcase_30 | AC | 5 ms
5,248 KB |
testcase_31 | AC | 6 ms
5,248 KB |
testcase_32 | AC | 4 ms
5,248 KB |
testcase_33 | AC | 4 ms
5,248 KB |
testcase_34 | AC | 80 ms
12,200 KB |
testcase_35 | AC | 150 ms
18,548 KB |
testcase_36 | AC | 85 ms
12,664 KB |
testcase_37 | AC | 80 ms
12,216 KB |
testcase_38 | AC | 106 ms
12,760 KB |
testcase_39 | AC | 109 ms
12,924 KB |
testcase_40 | AC | 85 ms
12,540 KB |
testcase_41 | AC | 153 ms
18,684 KB |
testcase_42 | AC | 108 ms
12,920 KB |
testcase_43 | AC | 152 ms
18,656 KB |
testcase_44 | AC | 111 ms
13,104 KB |
testcase_45 | AC | 159 ms
18,852 KB |
testcase_46 | AC | 153 ms
18,708 KB |
testcase_47 | AC | 109 ms
12,776 KB |
testcase_48 | AC | 151 ms
18,524 KB |
testcase_49 | AC | 112 ms
12,928 KB |
testcase_50 | AC | 83 ms
12,648 KB |
testcase_51 | AC | 106 ms
12,860 KB |
testcase_52 | AC | 79 ms
12,104 KB |
testcase_53 | AC | 155 ms
18,900 KB |
testcase_54 | AC | 155 ms
18,856 KB |
testcase_55 | AC | 154 ms
18,856 KB |
testcase_56 | AC | 156 ms
18,852 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using mint = modint998244353; using vm = vector<mint>; using vvm = vector<vm>; inline ostream &operator<<(ostream &os, const mint x) { return os << x.val(); }; inline istream &operator>>(istream &is, mint &x) { long long v; is >> v; x = v; return is; }; struct Fast { Fast() { std::cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(10); } } fast; #define all(a) (a).begin(), (a).end() #define contains(a, x) ((a).find(x) != (a).end()) #define rep(i, a, b) for (int i = (a); i < (int)(b); i++) #define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (a); i--) #define YN(b) cout << ((b) ? "YES" : "NO") << "\n"; #define Yn(b) cout << ((b) ? "Yes" : "No") << "\n"; #define yn(b) cout << ((b) ? "yes" : "no") << "\n"; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } using ll = long long; using vb = vector<bool>; using vvb = vector<vb>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) { for (int i = 0; i < (int)vec.size(); i++) { os << vec[i] << (i + 1 == (int)vec.size() ? "" : " "); } return os; } template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (int i = 0; i < (int)vec.size(); i++) is >> vec[i]; return is; } ll floor(ll a, ll b) { return a >= 0 ? a / b : (a + 1) / b - 1; } ll ceil(ll a, ll b) { return a > 0 ? (a - 1) / b + 1 : a / b; } template <typename mint> struct factorial { vector<mint> f, g, h; factorial(int MAX = 0) { f.resize(1, mint{1}); g.resize(1, mint{1}); h.resize(1, mint{1}); if (MAX > 0) extend(MAX + 1); } void extend(int m = -1) { int n = f.size(); if (m == -1) m = n * 2; if (n >= m) return; f.resize(m); g.resize(m); h.resize(m); for (int i = n; i < m; i++) f[i] = f[i - 1] * mint(i); g[m - 1] = f[m - 1].inv(); h[m - 1] = g[m - 1] * f[m - 2]; for (int i = m - 2; i >= n; i--) { g[i] = g[i + 1] * mint(i + 1); h[i] = g[i] * f[i - 1]; } } mint fact(int i) { if (i < 0) return mint(0); while (i >= (int)f.size()) extend(); return f[i]; } mint fact_inv(int i) { if (i < 0) return mint(0); while (i >= (int)g.size()) extend(); return g[i]; } mint inv(int i) { if (i < 0) return -inv(-i); while (i >= (int)h.size()) extend(); return h[i]; } mint binom(int n, int r) { if (n < 0 || n < r || r < 0) return mint(0); return fact(n) * fact_inv(n - r) * fact_inv(r); } mint multinom(const vector<int> &r) { int n = 0; for (auto &x : r) { if (x < 0) return mint(0); n += x; } mint res = fact(n); for (auto &x : r) res *= fact_inv(x); return res; } mint binom_naive(int n, int r) { if (n < 0 || n < r || r < 0) return mint(0); mint ret = mint(1); r = min(r, n - r); for (int i = 1; i <= r; ++i) ret *= inv(i) * (n--); return ret; } mint P(int n, int r) { if (n < 0 || n < r || r < 0) return mint(0); return fact(n) * fact_inv(n - r); } mint H(int n, int r) { if (n < 0 || r < 0) return mint(0); return r == 0 ? 1 : binom(n + r - 1, r); } }; void solve() { int n, k; cin >> n >> k; vm a(n); cin >> a; factorial<mint> fact(100000); if (k & 1) rep(i, 0, n) if (i & 1) a[i] = -a[i]; vm g(n); { int m = (k + 1) / 2; if (m) { mint p = 1; rep(i, 0, n) { g[i] = p * fact.fact_inv(i); p *= m + i; } a = convolution(a, g); } } { int m = k / 2; if (m) { mint p = 1; rep(i, 0, n) { g[i] = p * fact.fact_inv(i) * (i & 1 ? -1 : 1); p *= m + i; } a = convolution(a, g); } } rep(i, 0, n) cout << a[i] << " \n"[i + 1 == n]; } int main() { int t = 1; // cin >> t; while (t--) solve(); }