#P4148. 简单题

简单题

Description

You have an N×NN \times N board with an integer in each cell, all initially 00. You need to support three types of operations:

  • 1 x y A 1x,yN1\le x,y\le N, and AA is a positive integer. Add AA to the number in cell x, y.
  • 2 x1 y1 x2 y2 1x1x2N1 \le x_1 \le x_2 \le N, 1y1y2N1 \le y_1\le y_2 \le N. Output the sum of numbers inside the rectangle x1,y1,x2,y2x_1, y_1, x_2, y_2.
  • 3 None. Terminate the program.

Input Format

The first line contains a positive integer NN.

Each of the following lines contains one operation. For every command, all numbers after the first one must be XORed with the previous output answer last_ans. Initially, last_ans =0= 0.

Output Format

For each operation of type 22, output the corresponding answer.

4
1 2 3 3
2 1 1 3 3
1 1 1 1
2 1 1 0 7
3
3
5

Hint

Constraints: 1N5×1051\leq N\leq 5\times 10^5, the number of operations does not exceed 2×1052\times 10^5, memory limit 20MB20\texttt{MB}. It is guaranteed that answers fit in the range of int and that after decoding the testdata remains valid.

Translated by ChatGPT 5