一道ACM题 急求解!!!!!TLE了。。。

来源:百度知道 编辑:UC知道 时间:2024/06/04 08:26:51
Input
In the first line of the input file there is an Integer T(1<=T<=10), which means the number of test cases in the input file. Then N test cases are followed.
For each test case, in the first line there is an Integer Q(1<Q<100,000), means the queries of the case. Then followed by Q queries.
There are 4 kind of queries, sum, add, delete and move.
For example:
S x1 y1 x2 y2 means you should tell me the total books of the rectangle used (x1,y1)-(x2,y2) as the diagonal, including the two points.
A x1 y1 n1 means I put n1 books on the position (x1,y1)
D x1 y1 n1 means I move away n1 books on the position (x1,y1), if less than n1 books at that position, move away all of them.
M x1 y1 x2 y2 n1 means you move n1 books from (x1,y1) to (x2,y2), if less than n1 books at that position, move away all of them.
Make sure that at first, there is one book on every grid and 0<=x1,y1,x2,y2<=1000,1<=n1<=100.

Output
At

哪个OJ 给个链接 方便测试
这个题目的主要问题实际上是在于
0<=x1,y1,x2,y2<=1000
这个条件

这么大的空间 用什么方法来实现

这题就是很朴素的二维线段树..

不知道楼主原本是用什么算法做的? 不会是裸写的吧?