Gralerfics @ 2018-07-17 18:19:54
500x500有点不太好调Ummmmmm
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
template<typename Ty>void _read(Ty &x){
Ty _num=0,_fac=1;
char _peer=getchar();
for(;!isdigit(_peer);_peer=getchar())if(_peer=='-')_fac=-1;
for(;isdigit(_peer);_peer=getchar())_num=_num*10+_peer-'0';
x=_fac*_num;
}
int n,m,a[2505][2505];
int f[2505][2505],s[2505][2505];
int main(){
_read(n),_read(m);
int ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
_read(a[i][j]);
s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
if(a[i][j]>0&&s[i][j]-s[i-f[i-1][j-1]-1][j]-s[i][j-f[i-1][j-1]-1]+s[i-f[i-1][j-1]-1][j-f[i-1][j-1]-1]==f[i-1][j-1]+1)
f[i][j]=f[i-1][j-1]+1;
if(f[i][j]>ans)ans=f[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=m;j>=1;j--){
s[i][j]=s[i-1][j]+s[i][j+1]-s[i-1][j+1]+a[i][j];
if(a[i][j]>0&&s[i][j]-s[i-f[i-1][j+1]-1][j]-s[i][j+f[i-1][j+1]+1]+s[i-f[i-1][j+1]-1][j+f[i-1][j+1]+1]==f[i-1][j+1]+1)
f[i][j]=f[i-1][j+1]+1;
if(f[i][j]>ans)ans=f[i][j];
}
}
printf("%d\n",ans);
return 0;
}
by throusea @ 2018-07-24 21:14:33
me too!
by throusea @ 2018-07-24 21:22:20
提供一组hack数据。私信给你。
by throusea @ 2018-07-24 21:22:38
@wswzy233
by throusea @ 2018-07-24 21:23:31
弱弱地问:还要吗?
by Gralerfics @ 2018-07-24 21:30:52
@throusea 谢谢大佬!( ̄ε(# ̄)