Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
谁帮我找出错误数据我就服了他(她)了!!#include<stdio.h> #include<string.h> int arr[110][110]; int rec[110][110]; int main() { int max(int,int); int i,j,bmax; int r,c; scanf("%d %d",&r,&c); for(i=0;i<110;i++) for(j=0;j<110;j++) { arr[i][j]=-1; rec[i][j]=-1; } bmax=0; for(i=1;i<=r;i++) for(j=1;j<=c;j++) scanf("%d",&arr[i][j]); for(i=1;i<=r;i++) for(j=1;j<=c;j++) { if(max(i,j)>bmax) bmax=rec[i][j]; } printf("%d\n",bmax); return 0; } int max(int n,int m) { int amax=0; if(arr[n][m]<=arr[n+1][m]&&arr[n][m]<=arr[n-1][m]&&arr[n][m]<=arr[n][m+1]&&arr[n][m]<=arr[n][m-1]) return 1; if(rec[n][m]!=-1) return rec[n][m]; if(arr[n+1][m]<arr[n][m] && arr[n+1][m]>=0) if(max(n+1,m)>amax) amax=rec[n+1][m]; if(arr[n-1][m]<arr[n][m] && arr[n-1][m]>=0) if(max(n-1,m)>amax) amax=rec[n-1][m]; if(arr[n][m+1]<arr[n][m] && arr[n][m+1]>=0) if(max(n,m+1)>amax) amax=rec[n][m+1]; if(arr[n][m-1]<arr[n][m] && arr[n][m-1]>=0) if(max(n,m-1)>amax) amax=rec[n][m-1]; rec[n][m]=amax+1; return amax+1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator