| 比赛 | 
    20110728 | 
    评测结果 | 
    AATEEEEEEE | 
    | 题目名称 | 
    蝗灾 | 
    最终得分 | 
    20 | 
    | 用户昵称 | 
    kaaala | 
    运行时间 | 
    0.000 s  | 
    | 代码语言 | 
    C++ | 
    内存使用 | 
    0.00 MiB  | 
    | 提交时间 | 
    2011-07-28 09:16:21 | 
显示代码纯文本
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
long a[2001][2001],n,w,ans,x,x2,y,y2,z;
bool f=false;
int main()
{
	long i,j,k,l;
	freopen("locust.in","r",stdin);
	freopen("locust.out","w",stdout);
	scanf("%d",&w);
	scanf("%d",&n);
	memset(a,0,sizeof(a));
	for(k=1;k<=n;k++)
	{
		ans=0;
		scanf("%d",&l);
		if(l==2&&!f)
		{
			scanf("%d%d%d%d",&x,&y,&x2,&y2);
			printf("0\n");
			continue;
		}
		if(l==2&&f)
		{
			scanf("%d%d%d%d",&x,&y,&x2,&y2);
			for(i=x;i<=x2;i++)
				for(j=y;j<=y2;j++)
					ans+=a[i][j];
			printf("%d\n",ans);
			continue;
		}
		if(l==1)
		{
			scanf("%d%d%d",&x,&y,&z);
			a[x][y]+=z;
			f=true;
		}
	}
	return 0;
}