結果

問題 No.1172 Add Recursive Sequence
ユーザー nikkukunnikkukun
提出日時 2020-08-14 23:13:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,729 bytes
コンパイル時間 1,902 ms
コンパイル使用メモリ 168,552 KB
実行使用メモリ 15,756 KB
最終ジャッジ日時 2024-04-18 23:05:52
合計ジャッジ時間 4,448 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 4 ms
11,488 KB
testcase_03 AC 4 ms
10,804 KB
testcase_04 AC 4 ms
10,584 KB
testcase_05 AC 5 ms
11,008 KB
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 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// 21:41 - 21:56
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef tuple<int, int, int> tint;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

vector<int> in[N], out[N];
int l[N], r[N]; // [l, r)
ll a[N], c[N];
ll f[N], g[N];

int main() {
	ios::sync_with_stdio(0);

	int len, n, m;
	cin >> len >> n >> m;
	for (int i = 0; i < len; i++)
		cin >> a[i];
	for (int i = 1; i <= len; i++)
		cin >> c[i];
	for (int i = 1; i <= m; i++) {
		cin >> l[i] >> r[i];
		in[l[i]].push_back(i);
		out[r[i]].push_back(i);
	}

	for (int i = len; i < n; i++)
		for (int j = 1; j <= len; j++)
			a[i] = (a[i] + a[i - j] * c[j]) % MOD;

	for (int i = 0; i < n; i++) {
		// add in
		if (i - len >= 0) {
			for (auto j: in[i - len]) {
				if (r[j] - l[j] < len) continue;
				for (int k = 1; k <= len; k++)
					g[i - k] = (g[i - k] + a[len - k]) % MOD;
			}
		}
		// remove out
		for (auto j: out[i]) {
			if (r[j] - l[j] < len) continue;
			int now = r[j] - l[j];
			for (int k = 1; k <= len; k++)
				g[i - k] = (g[i - k] - a[now - k]) % MOD;
		}
		// not in g
		for (int j = 0; j < len; j++) {
			if (i - j < 0) continue;
			for (auto k: in[i - j]) {
				if (r[k] <= i) continue;
				f[i] = (f[i] + a[j]) % MOD;
			}
		}
		// in g
		for (int j = 1; j <= len; j++) {
			f[i] = (f[i] + g[i - j] * c[j]) % MOD;
			g[i] = (g[i] + g[i - j] * c[j]) % MOD;
		}
	}

	for (int i = 0; i < n; i++) {
		f[i] = (f[i] % MOD + MOD) % MOD;
		cout << f[i] << endl;
	}

	return 0;
}
0