結果

問題 No.1172 Add Recursive Sequence
ユーザー optopt
提出日時 2020-05-22 13:23:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,516 bytes
コンパイル時間 2,137 ms
コンパイル使用メモリ 200,288 KB
実行使用メモリ 13,888 KB
最終ジャッジ日時 2024-04-17 06:58:52
合計ジャッジ時間 8,100 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 TLE -
testcase_17 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In constructor 'mint::mint(ll)':
main.cpp:11:21: warning: '*this.mint::x' is used uninitialized [-Wuninitialized]
   11 |   mint(ll xx=0) : x(x) {}
      |                     ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define rep(i, n) rep2(i, 0, n)
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
const int MOD = int(1e9) + 7;

struct mint {
  ll x;
  mint(ll xx=0) : x(x) {}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
  mint& operator-=(const mint a) { if ((x -= a.x) < 0) x += MOD; return *this; }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
using Vm = vector<mint>;


int main() {
  int k, n, m; cin >> k >> n >> m;
  Vm a(k+n), c(k+1);
  c[0] = -1;
  rep(i, k) cin >> a[i];
  rep(i, k) cin >> c[i+1];
  rep2(i, k, n+k) rep2(j, 1, k+1) a[i] += c[j]*a[i-j];

  Vm y(n);
  rep(_, m) {
    int l, r; cin >> l >> r;
    rep(i, k) rep(j, k-i) if (l+i+j < n) y[l+i+j] -= c[i] * a[j];
    rep(i, k) rep(j, k-i) if (r+i+j < n) y[r+i+j] += c[i] * a[r-l+j];
  }

  Vm x(n+k);
  rep(i, n) {
    x[k+i] = y[i];
    rep2(j, 1, k+1) x[k+i] += c[j] * x[k+i-j];
    cout << x[k+i] << "\n";
  }
  return 0;
}
0