帮帮孩子吧,最后一个点WA疯了
查看原帖
帮帮孩子吧,最后一个点WA疯了
420731
baizhiheizi楼主2021/4/9 23:08
#include <iostream>
#include <cstdio>
#include <string.h> 
#include <algorithm>
#define LL long long 
using namespace std;
const int maxn=2010;
LL maze[maxn][maxn];
LL s[maxn][maxn];
LL n,m,c,max_=1e-9,p,q;

LL mx(LL x1,LL y1){
	return s[x1+c-1][y1+c-1]-s[x1-1][y1+c-1]-s[x1+c-1][y1-1]+s[x1-1][y1-1];
	//return res;	
}

int main(){
	scanf("%lld %lld %lld",&n,&m,&c);
	for(LL i=1;i<=n;i++){
		for(LL j=1;j<=m;j++){
			cin>>maze[i][j];
		}
	}
	s[1][1]=maze[1][1];
	for(LL i=1;i<=n;i++){
		for(LL j=1;j<=n;j++){
			if(i!=1||j!=1)s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+maze[i][j];
		}
	}
	for(LL i=1;i<=n;i++){
		for(LL j=1;j<=m;j++){
			if(i+c>n||j+c>m)continue;
			LL res=mx(i,j);
			if(max_<res){
				max_=res;
				p=i;
				q=j;
			}
		}
	}
	cout<<p<<" "<<q<<endl;
	return 0;
}
2021/4/9 23:08
加载中...