結果

問題 No.1172 Add Recursive Sequence
ユーザー optopt
提出日時 2020-08-10 23:48:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 974 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 198,308 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2024-04-17 07:42:27
合計ジャッジ時間 12,159 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,112 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 49 ms
5,376 KB
testcase_11 AC 46 ms
5,376 KB
testcase_12 AC 64 ms
5,376 KB
testcase_13 AC 59 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 TLE -
testcase_17 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define rep(i, n) rep2(i, 0, n)
using ll = long long;
using Vll = vector<ll>;
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;


int main() {
  int k, n, m; cin >> k >> n >> m;
  Vll 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) rep2(j, 1, k+1) (a[i] += c[j] * a[i-j]) %= MOD;

  Vll y(n);
  rep(q, m) {
    int l, r; cin >> l >> r;
    rep2(i, l, min(l+k, n)) rep(j, i-l+1) y[i] += c[j] * a[i-l-j];
    rep2(i, r, min(r+k, n)) rep(j, i-r+1) y[i] -= c[j] * a[i-l-j];
    if (q % 20 == 0) rep(i, n) y[n] %= MOD;
  }
  rep(i, n) y[n] %= MOD;

  Vll x(n);
  rep(i, n) {
    x[i] = - y[i];
    rep2(j, 1, min(i, k)+1) x[i] += c[j] * x[i-j];
    x[i] = (x[i] % MOD + MOD) % MOD;
    cout << x[i] << '\n';
  }
  return 0;
}
0