結果

問題 No.1172 Add Recursive Sequence
ユーザー FF256grhyFF256grhy
提出日時 2020-08-14 22:54:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 3,654 bytes
コンパイル時間 2,295 ms
コンパイル使用メモリ 201,024 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-18 22:42:05
合計ジャッジ時間 10,535 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
// 以下、入出力関係のテンプレ案のテスト
auto * IS = & cin;
// input elements (as a tuple)
template<typename U, int I> void in_(U & t) { }
template<typename U, int I, typename A, typename ... B> void in_(U & t) { (* IS) >> get<I>(t); in_<U, I + 1, B ...>(t); }
template<typename ... T> auto in() { tuple<T ...> t; in_<tuple<T ...>, 0, T ...>(t); return t; }
// input a array
template<typename T, int N> auto ain() { array<T, N> a; inc(i, N) { (* IS) >> a[i]; } return a; }
// input a (multi-dimensional) vector
template<typename T> T vin() { return * istream_iterator<T>(* IS); }
template<typename T, typename N, typename ... M> auto vin(N n, M ... m) {
	vector<decltype(vin<T, M ...>(m ...))> v(n); inc(i, n) { v[i] = vin<T, M ...>(m ...); } return v;
}
// input multi-column (as a tuple of vector)
template<typename U, int I> void colin_(U & t) { }
template<typename U, int I, typename A, typename ... B> void colin_(U & t) {
	get<I>(t).emplace_back(* istream_iterator<A>(* IS)); colin_<U, I + 1, B ...>(t);
}
template<typename ... T> auto colin(int n) {
	tuple<vector<T> ...> t; inc(i, n) { colin_<tuple<vector<T> ...>, 0, T ...>(t); } return t;
}
auto * OS = & cout;
string SP = " ", LN = "\n";
// output elements
void out() { (* OS) << LN << flush; }
template<typename A                > void out(A && a            ) { (* OS) << a      ; out(     ); }
template<typename A, typename ... B> void out(A && a, B && ... b) { (* OS) << a << SP; out(b ...); }
// output a (multi-dimensional) vector
template<typename T> ostream & operator<<(ostream & os, vector<T> const & v) {
	inc(i, v.size()) { os << (i == 0 ? "" : SP) << v[i]; } return os << flush;
}
template<typename T> void vout_(T && v) { (* OS) << v; }
template<typename T, typename A, typename ... B> void vout_(T && v, A a, B ... b) {
	for(auto && w: v) { vout_(w, b ...); (* OS) << a; }
}
template<typename T, typename ... A> void vout(T && v, A ... a) { vout_(v, a ...); out(); }

// ---- ----

const int MOD = 1'000'000'007;

// test

int main() {
	auto [k, n, m] = ain<int, 3>();
	auto a = vin<LL>(k);
	auto c = vin<LL>(k);
	inc(i, n) {
		if(i < k) { continue; }
		LL s = 0;
		inc(j, k) { (s += c[j] * a[i - 1 - j]) %= MOD; }
		a.PB(s);
	}
	
	vector<LL> x(n);
	inc(i, m) {
		auto [l, r] = in<int, int>();
		incID(i, l, r) { x[i] += a[i - l]; }
	}
	RF(e, x) { e %= MOD; }
	LN = "";
	vout(x, "\n");
}
0