結果

問題 No.1574 Swap and Repaint
ユーザー risujirohrisujiroh
提出日時 2021-06-27 15:12:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,047 bytes
コンパイル時間 2,209 ms
コンパイル使用メモリ 200,048 KB
最終ジャッジ日時 2025-01-22 14:30:56
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 TLE * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/modint>

int main() {
  using namespace std;
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  using Mint = atcoder::modint998244353;
  vector<Mint> a(n);
  for (auto&& e : a) {
    int v;
    cin >> v;
    e = Mint::raw(v);
  }
  vector<Mint> c(n);
  c[0] = 1 / Mint(2);
  for (int i = 1; i < n - 1; ++i) c[i] = c[i - 1] / (2 * i + 2);
  for (int i = 0; i < n - 1; ++i) c[i] = 1 - c[i];
  c.back() = n - accumulate(begin(c), end(c) - 1, Mint(0));
  Mint coeff = 1;
  for (int i = 1; i < n; ++i) coeff *= 4 * i;
  for (int s = 0; s <= n; ++s) {
    Mint ans;
    for (int i = 0; i < n; ++i) ans += c[i] * a[i];
    ans *= coeff;
    cout << ans.val() << '\n';
    vector<Mint> na(n);
    na[0] += a[0] * (n - 2);
    na[1] += a[0];
    for (int i = 1; i < n - 1; ++i) {
      na[i - 1] += a[i];
      na[i] += a[i] * (n - 3);
      na[i + 1] += a[i];
    }
    na[n - 2] += a[n - 1];
    na[n - 1] += a[n - 1] * (n - 2);
    a = move(na);
  }
}
0