好吧,如果说D1T1是纯模拟大水题
D2T1就是纯模拟略水题。
这道题首先我们要看一看数据范围。。
0<=n,m<=128
送分也不带这么送的吧。。
二维前缀和,前缀和,二次循环,4次循环,随你怎么乱搞都能过。。
没有任何需要提醒的东西。。
水~
下面贴代码
#include<iostream> #include<cstdio> using namespace std; int gg[130][130]; int ans1=0,sum,x,y,ans2=0,d,n,lx,ly,rx,ry; int main(){ scanf("%d%d",&d,&n); for(int i=1;i<=n;i++) { int x,y,z; scanf("%d%d%d",&x,&y,&z); gg[x][y]=z; } for(int i=0;i<=128;i++) for(int j=0;j<=128;j++) { lx=max(0,i-d),rx=min(i+d,128); ly=max(0,j-d),ry=min(j+d,128); for(sum=0,x=lx;x<=rx;x++) for(y=ly;y<=ry;y++) sum+=gg[x][y]; if(sum>ans2)ans2=sum,ans1=1; else if(sum==ans2)ans1++; } printf("%d %d ",ans1,ans2); return 0; }