#P6588. 『JROI-1』 向量

『JROI-1』 向量

Description

Little L has nn vectors $\overrightarrow{a_1},\overrightarrow{a_2}\ldots\overrightarrow{a_n}$, and he wants you to help him answer the following two questions.

  • For a given l,rl,r, compute
$$\sum\limits_{i=l}^{r-1}\sum\limits_{j=i+1}^{r}\overrightarrow{a_i}\cdot\overrightarrow{a_j}$$
  • For a given l,rl,r, compute
$$\sum\limits_{i=l}^{r-1}\sum\limits_{j=i+1}^{r}\overrightarrow{a_i}\oplus\overrightarrow{a_j}$$

As time goes by, these vectors will also keep changing. Little L hopes that after changes happen, you can still give the answers.

Input Format

The first line contains two integers n,mn,m, representing the number of vectors and the number of operations.

The next nn lines each contain two integers x,yx,y. The ii-th line represents the vector ai\overrightarrow{a_i}.

The next mm lines each start with an integer optopt indicating the operation type, followed by several integers describing the operation. There are five types of operations as follows.

  1. Input three integers i,x,y(1in)i,x,y(1\leq i\leq n), add (x,y)(x,y) to ai\overrightarrow{a_i}.
  2. Input three integers i,x,y(1in)i,x,y(1\leq i\leq n), subtract (x,y)(x,y) from ai\overrightarrow{a_i}.
  3. Input two integers i,t(1in)i,t(1\leq i\leq n), modify ai\overrightarrow{a_i} to tait\overrightarrow{a_i}.
  4. Input two integers l,r(1l<rn)l,r(1\leq l<r\leq n), compute $\sum\limits_{i=l}^{r-1}\sum\limits_{j=i+1}^{r}\overrightarrow{a_i}\cdot\overrightarrow{a_j}$.
  5. Input two integers l,r(1l<rn)l,r(1\leq l<r\leq n), compute $\sum\limits_{i=l}^{r-1}\sum\limits_{j=i+1}^{r}\overrightarrow{a_i}\oplus\overrightarrow{a_j}$.

Output Format

For every operation of type 4 and type 5, output one line containing one integer, the answer to this operation.

3 5
1 1
4 5
1 4
1 1 3 6
2 3 3 0
4 2 3
3 2 3
5 1 3
12
84

Hint

Explanation for Sample 1

After the first two operations, the three vectors are (4,7),(4,5),(2,4)(4,7),(4,5),(-2,4). Then the query result is 4×(2)+5×4=124\times(-2)+5\times4=12.

After the next operation, the three vectors are (4,7),(12,15),(2,4)(4,7),(12,15),(-2,4). The query result is $(4\times15-7\times12)+[4\times4-7\times(-2)]+[12\times4-15\times(-2)]=-24+30+78=84$.


Constraints

This problem uses bundled testdata.

  • Subtask 1 ( 20%20\% ): n,m100n,m\leq 100.
  • Subtask 2 ( 30%30\% ): there is no operation type 5.
  • Subtask 3 ( 50%50\% ): no special requirements.

For 100%100\% of the data, 2n1052\leq n\leq 10^5, 1m1051\leq m\leq 10^5, and it is guaranteed that for the vector ai\overrightarrow{a_i} at any time, 1000xi,yi1000-1000\leq x_i,y_i\leq 1000.


About Vector Operations

For vectors a,b\overrightarrow{a},\overrightarrow{b} and a constant λ\lambda, suppose the coordinate representations of a,b\overrightarrow{a},\overrightarrow{b} are (xa,ya),(xb,yb)(x_a,y_a),(x_b,y_b):

  • $\overrightarrow{a}+\overrightarrow{b}=(x_a+x_b,y_a+y_b)$
  • $\overrightarrow{a}-\overrightarrow{b}=(x_a-x_b,y_a-y_b)$
  • $\lambda\overrightarrow{a}=(\lambda x_a,\lambda y_a)$
  • $\overrightarrow{a}\cdot\overrightarrow{b}=x_ax_b+y_ay_b$
  • $\overrightarrow{a}\oplus\overrightarrow{b}=x_ay_b-x_by_a$

Translated by ChatGPT 5