Main » 2013 September 27 » 疯狂卡时 [NOIP2012模拟赛No.10]创意吃鱼法
3:46 PM 疯狂卡时 [NOIP2012模拟赛No.10]创意吃鱼法 |
#include<cstdio> #include<cstdlib> #include<cstring> #define N 2510 int min(int a,int b) { if (a<b) return a; return b; } int n,t,x,y,map[N][N],i,j,left[N][N],up[N][N],dp[N][N],m; int main() { scanf("%d %d",&n,&m); memset(map,0,sizeof(map)); for (i=1;i<=n;i++) for (j=1;j<=m;j++) { scanf("%d",&map[i][j]); if (!map[i][j]) up[i][j]=up[i-1][j]+1; } int max=0; for (i=1;i<=n;i++) for (j=1;j<=m;j++) if (map[i][j]) { left[i][j]=0; dp[i][j]=min(dp[i-1][j-1],min(left[i][j-1],up[i-1][j]))+1; if (dp[i][j]>max) max=dp[i][j]; }else left[i][j]=left[i][j-1]+1; int t; for (i=1;i<=n;i++) for (j=m;j>=1;j--) if (map[i][j]) { left[i][j]=0; dp[i][j]=min(dp[i-1][j+1],min(left[i][j+1],up[i-1][j]))+1; if (dp[i][j]>max) max=dp[i][j]; }else left[i][j]=left[i][j+1]+1; printf("%d\n",max); }
|
|
Total comments: 0 | |