题库练习 Two Arrays
← 上一题 下一题 →

A14589 | Two Arrays

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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 $Ak_i:=min(Ak_i, x)$ for each $l \leq i \leq r$ .

2 k l r x: set $Ak_i:=max(Ak_i, x)$ for each $l \leq i \leq r$ .

3 k l r x: set $Ak_i:=Ak_i+x$ for each $l \leq i \leq r$ .

4 l r: find the $(\sum_{i=l}^r F(A1_i+A2_i)) \% (10^9+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.

输入格式

The first line contains two integers $N$ and $Q$ . ( $1 \leq N, Q \leq 5 \times 10^4$ )

The second line contains $N$ integers, array $A1_1, A1_2, \dots A1_N$ . ( $0 \leq A1_i \leq 10^6$ )

The third line contains $N$ integers, array $A2_1, A2_2, \dots A2_N$ . ( $0 \leq A2_i \leq 10^6$ )

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 \in \{1, 2\}$ , $1 \leq l \leq r \leq N$ )

For queries of type 1 and 2, $0 \leq x \leq 10^9$ holds.

For queries of type 3, $−10^6 \leq x \leq 10^6$ holds.

It is guaranteed that after every query each number in arrays $A1$ and $A2$ will be nonnegative.

输出格式

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
C++ 编辑器
输入
输出