結果
| 問題 |
No.1172 Add Recursive Sequence
|
| コンテスト | |
| ユーザー |
cookiedoth
|
| 提出日時 | 2020-08-14 22:34:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 379 ms / 4,000 ms |
| コード長 | 2,884 bytes |
| コンパイル時間 | 1,278 ms |
| コンパイル使用メモリ | 127,252 KB |
| 最終ジャッジ日時 | 2025-01-13 00:15:07 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
/*
Code for problem E by cookiedoth
Generated 14 Aug 2020 at 04.17 PM
▅███████ ]▄▄▄▄▄▄▄
█████████▅▄▃
Il████████████████]
◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤
z_z
=_=
¯\_(ツ)_/¯
*/
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define debug(a) cerr << #a << " = " << a << endl
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()
using namespace std;
template<class T> int chkmax(T &a, T b) {
if (b > a) {
a = b;
return 1;
}
return 0;
}
template<class T> int chkmin(T &a, T b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
template<class iterator> void output(iterator begin, iterator end, ostream& out = cerr) {
while (begin != end) {
out << (*begin) << " ";
begin++;
}
out << endl;
}
template<class T> void output(T x, ostream& out = cerr) {
output(x.begin(), x.end(), out);
}
void fast_io() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
const int MOD = 1e9 + 7;
int mul(int a, int b) {
return (1LL * a * b) % MOD;
}
int diff(int a, int b) {
a -= b;
if (a < 0) {
a += MOD;
}
return a;
}
void add(int &a, const int &b) {
a += b;
if (a >= MOD) {
a -= MOD;
}
}
const int MAX_K = 210;
const int mx = 1e5 + 228;
int k, n, m, a[mx], c[MAX_K], val[mx][MAX_K], arr[mx];
void read() {
cin >> k >> n >> m;
for (int i = 0; i < k; ++i) {
cin >> a[i];
}
for (int i = 1; i <= k; ++i) {
cin >> c[i];
}
for (int i = k; i <= n; ++i) {
for (int j = 1; j <= k; ++j) {
add(a[i], mul(c[j], a[i - j]));
}
}
for (int i = 0; i < m; ++i) {
int l, r;
cin >> l >> r;
r--;
for (int j = l; j < min(l + k, r + 1); ++j) {
add(arr[j], a[j - l]);
}
if (r >= l + k) {
for (int j = 0; j < k; ++j) {
add(val[l + k][j], a[j]);
add(val[r + 1][j], (MOD - a[r - l - k + j + 1]) % MOD);
}
}
}
}
int cur_val[MAX_K];
void process() {
for (int i = 0; i < n; ++i) {
for (int j = 0; j < k; ++j) {
add(cur_val[j], val[i][j]);
}
cur_val[k] = 0;
for (int j = 0; j < k; ++j) {
add(cur_val[k], mul(cur_val[j], c[k - j]));
}
add(arr[i], cur_val[k]);
for (int j = 0; j < k; ++j) {
cur_val[j] = cur_val[j + 1];
}
}
}
void print_ans() {
for (int i = 0; i < n; ++i) {
cout << arr[i] << '\n';
}
}
signed main() {
fast_io();
read();
process();
print_ans();
}
cookiedoth