#P4514. 上帝造题的七分钟
上帝造题的七分钟
Description
“Minute 1: X said, let there be a matrix, and so there was an matrix filled with .
Minute 2: L said, let it support modifications, and so there was an operation that adds a value to all numbers in a rectangular region whose top-left corner is and bottom-right corner is .
Minute 3: k said, let it support queries, and so there was an operation that computes the sum of all numbers in a given rectangular region.
Minute 4: Rainbow Meow said, it should be based on a data structure related to binary trees, and so there were the Constraints.
Minute 5: Hexue said, be patient, and so there was a time limit.
Minute 6: The piano-eating guy said, save some trouble, and so there was a restriction that during the operations and in the final result, everything will not exceed the range of a 32-bit signed integer type.
Minute 7: This problem was finally completed. However, the godlike problem setters no longer wanted to write the program for it.”.
— “Seven Minutes of God Making a Naked Problem”.
So this sacred task is handed over to you.
Input Format
The first line of the input is X n m, indicating that the matrix size is .
From the second line to the end of the file, each line contains one of the following two operations:
L a b c d delta— add to all numbers in the rectangular region with vertices and .k a b c d— compute the sum of all numbers in the rectangular region with vertices and .
Note that is lowercase.
Output Format
For each k operation, output the answer on a separate line.
X 4 4
L 1 1 3 3 2
L 2 2 4 4 1
k 2 2 3 3
12
Hint
For of the testdata, , , and there are no more than operations.
For of the testdata, , .
For of the testdata, , , , and there are no more than operations. It is guaranteed that the final results do not exceed the range of a 32-bit signed integer type, but it is not guaranteed that intermediate computations stay within this range.
Translated by ChatGPT 5
京公网安备 11011102002149号