#P3328. [SDOI2015] 音质检测

[SDOI2015] 音质检测

Description

Boss Wan wants to implement an evaluation of the audio quality performance of wave files in the new smart music player IPOOD\operatorname{IPOOD}. A discrete wave file is considered as an integer sequence of length NN: A1,A2,,ANA_1, A_2, \cdots, A_N. The audio quality evaluation can be computed for any interval [L,R][L, R], and the score depends on the following expression:

$$\sum_{L<i<R}F[A_{i-1}+1]F[A_{i+1}-1] \operatorname{mod}\;(10^9+7)$$

Here FF is an inductively defined sequence, satisfying F1=1F_1=1, F2=2F_2=2, and Fk+2=Fk+1+aFk+bF_{k+2}=F_{k+1}+aF_{k}+b for any k>0k>0.

Here aa and bb are non-negative integer coefficients. To provide a better user experience and to allow optimization of the given wave file, the device should also support modifications to the wave file. For a given interval [L,R][L, R], the user is allowed to increase ALA_L through ARA_R by one simultaneously, or decrease them by one simultaneously.

Input Format

The first line contains two positive integers: the total length NN of the wave file, and the total number QQ of modifications and queries.

The second line contains two integers, the coefficients aa and bb.

Then, over several lines, NN positive integers A1A_1 through ANA_N are given, satisfying 1Ai2×1091 \leq A_i \leq 2 \times 10^9.

Then follow QQ lines, each in one of the following three forms:

  • plus  L  R:\text{plus}\;L\;R: increase every element with index in [L,R][L, R] by one.
  • minus  L  R:\text{minus}\;L\;R: decrease every element with index in [L,R][L, R] by one.
  • query  L  R:\text{query}\;L\;R: ask for the audio quality score of the interval [L,R][L, R]. In both modifications and queries, it is guaranteed that LRL \leq R, and that AiA_i is strictly greater than the total number of modifications plus one (modification operations include both plus\text{plus} and minus\text{minus}).

Output Format

Output several lines, each corresponding to one query. For each query, output one integer.

7 7
1 0
3 4 5 6 7 8 9
query 2 4
query 3 7
plus 3 5
query 2 4
plus 4 7
query 3 7
query 1 7
64 
1766 
104 
7479 
7687

Hint

N3×105,Q104,0a,b109N\leq 3\times10^5,Q\leq10^4,0\leq a,b\leq10^9.

Translated by ChatGPT 5