CF1599E Two Arrays
题目描述
给定两个长度为 $N$ 的整数列,$A1$ 和 $A2$ 。有以下四种操作 :
- 操作 $1$: 格式:`1 k l r x` 含义:将第 $k$ 个数列在区间 $[l,r]$ 内的所有数与 $x$ 取 $\min$ 。
- 操作 $2$: 格式:`2 k l r x` 含义:将第 $k$ 个数列在区间 $[l,r]$ 内的所有数与 $x$ 取 $\max$ 。
- 操作 $3$:格式: `3 k l r x` 含义:将第 $k$ 个数列在区间 $[l,r]$ 内的所有数加上 $x$ 。
- 操作 $4$:格式: `4 l r` 含义:输出 $\sum^r_{i=l}F(A1_i+A2_i)$,其中 $F(k)$ 表示第 $k$ 个斐波那契数 $(F(0)=0,F(1)=1,F(k)=F(k-1)+F(k-2))$,输出对 $10^9+7$ 取模 。
输入格式
第一行包含两个整数 $N$ 和 $Q$,分别表示数列的长度和操作数 $(1\leq N,Q\leq 5\times 10^4)$ 。
第二行包含 $N$ 个整数,表示数列 $A1$ 。$(0\leq A1_i\leq 10^6)$
第三行包含 $N$ 个整数,表示数列 $A2$ 。$(0\leq A2_i\leq 10^6)$
接下来 $Q$ 行,每行表示一次操作 。$(k\in \{ 1,2\},1\leq l\leq r\leq N)$
对于操作 $1$ 和 $2$,$0\leq x\leq 10^9$ 。
对于操作 $3$,$-10^6\leq x\leq10^6$ 。
**数据保证在每一次操作后数列里的数都不为负 。**
输出格式
对于每一个操作 $4$ ,输出一行一个整数,表示答案 。
说明/提示
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 $ .