CF1599E.Two Arrays
NOI/NOI+/CTSC
通过率:0%
时间限制:5.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given two integer arrays of length N, A1 and A2. You are also given Q queries of 4 types:
1 k l r x: set Aki:=min(Aki,x) for each l≤i≤r.
2 k l r x: set Aki:=max(Aki,x) for each l≤i≤r.
3 k l r x: set Aki:=Aki+x for each l≤i≤r.
4 l r: find the (∑i=lrF(A1i+A2i))%(109+7) where F(k) is the k-th Fibonacci number (F(0)=0,F(1)=1,F(k)=F(k−1)+F(k−2)), and x%y denotes the remainder of the division of x by y.
You should process these queries and answer each query of the fourth type.
给你两个长度为 N 的整数数组 A1 和 A2,以及 Q 个四种类型的查询:
-
1 k l r x:对每个满足 l≤i≤r 的下标 i,执行 Aki:=min(Aki,x)。 -
2 k l r x:对每个满足 l≤i≤r 的下标 i,执行 Aki:=max(Aki,x)。 -
3 k l r x:对每个满足 l≤i≤r 的下标 i,执行 Aki:=Aki+x。 -
4 l r:计算 (∑i=lrF(A1i+A2i))mod(109+7),其中 F(k) 表示第 k 个斐波那契数(定义为 F(0)=0, F(1)=1, F(k)=F(k−1)+F(k−2)),而 xmody 表示 x 除以 y 所得的余数。
你需要依次处理所有查询,并对每个第 4 类查询输出对应答案。
输入格式
The first line contains two integers N and Q. (1≤N,Q≤5×104)
The second line contains N integers, array A11,A12,…A1N. (0≤A1i≤106)
The third line contains N integers, array A21,A22,…A2N. (0≤A2i≤106)
The next Q lines describe the queries. Each line contains 5 or 3 integers, where the first integer denotes the type of the query. (k∈1,2, 1≤l≤r≤N)
For queries of type 1 and 2, 0≤x≤109 holds.
For queries of type 3, −106≤x≤106 holds.
It is guaranteed that after every query each number in arrays A1 and A2 will be nonnegative.
第一行包含两个整数 N 和 Q。(1≤N,Q≤5×104)
第二行包含 N 个整数,表示数组 A11,A12,…,A1N。(0≤A1i≤106)
第三行包含 N 个整数,表示数组 A21,A22,…,A2N。(0≤A2i≤106)
接下来的 Q 行描述查询操作。每行包含 5 个或 3 个整数,其中第一个整数表示查询类型。(k∈{1,2},1≤l≤r≤N)
对于类型为 1 和 2 的查询,满足 0≤x≤109。
对于类型为 3 的查询,满足 −106≤x≤106。
保证每次查询操作后,数组 A1 和 A2 中的每个数均为非负数。
输出格式
Print the answer to each query of the fourth type, in separate lines.
打印每个第四类查询的答案,每行一个。
输入输出样例
输入#1
3 4 1 0 2 2 1 0 4 1 3 3 2 2 2 3 1 1 1 3 0 4 1 3
输出#1
4 4
输入#2
5 4 1 3 5 3 2 4 2 1 3 3 4 1 3 4 2 5 2 1 2 4 6 4 2 4
输出#2
18 26 68
说明/提示
In the first example: The answer for the first query is F(1+2)+F(0+1)+F(2+0)=F(3)+F(1)+F(2)=2+1+1=4. After the second query, the array A2 changes to [2,4,0]. After the third query, the array A1 changes to [0,0,0]. The answer for the fourth query is F(0+2)+F(0+4)+F(0+0)=F(2)+F(4)+F(0)=1+3+0=4.
In the second example: The answer for the first query is F(1+4)+F(3+2)+F(5+1)=F(5)+F(5)+F(6)=5+5+8=18. The answer for the second query is F(3+2)+F(5+1)+F(3+3)+F(2+3)=F(5)+F(6)+F(6)+F(5)=5+8+8+5=26. After the third query, the array A1 changes to [1,6,6,6,2]. The answer for the fourth query is F(6+2)+F(6+1)+F(6+3)=F(8)+F(7)+F(9)=21+13+34=68.
在第一个例子中:第一个查询的答案为 F(1+2)+F(0+1)+F(2+0)=F(3)+F(1)+F(2)=2+1+1=4。第二个查询之后,数组 A2 变为 [2,4,0]。第三个查询之后,数组 A1 变为 [0,0,0]。第四个查询的答案为 F(0+2)+F(0+4)+F(0+0)=F(2)+F(4)+F(0)=1+3+0=4。
在第二个例子中:第一个查询的答案为 F(1+4)+F(3+2)+F(5+1)=F(5)+F(5)+F(6)=5+5+8=18。第二个查询的答案为 F(3+2)+F(5+1)+F(3+3)+F(2+3)=F(5)+F(6)+F(6)+F(5)=5+8+8+5=26。第三个查询之后,数组 A1 变为 [1,6,6,6,2]。第四个查询的答案为 F(6+2)+F(6+1)+F(6+3)=F(8)+F(7)+F(9)=21+13+34=68。
输入解题思路,AI测评打分。不知道怎么写?