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 |
不知道为什么老是 runtime error 希望NB的人可以路过#include <iostream> // using namespace std; int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}}; int a[501][501]; int ret[501][501]; int c=0; int r=0; int i1; int zhi; int x1; int y1; int da; int dfs(int I,int J) { if(ret[I][J]>=0) return ret[I][J]; for(i1=0;i1<=3;i1++) { x1=I+dir[i1][0]; y1=J+dir[i1][1]; if(x1>=0&&x1<=r&&y1>=0&&y1<=c) { if(a[I][J]>=a[x1][y1]) { zhi=dfs(x1,y1); zhi++; if(da<=zhi) da=zhi; } } } ret[I][J]=da; return ret[I][J]; } int main() { int i=0; int j=0; int max=0; while(scanf("%d%d",&r,&c)) { r--; c--; max=0; for(i=0;i<=500;i++) { for(j=0;j<=500;j++) { a[i][j]=0; ret[i][j]=-1; } } for(i=0;i<=r;i++) { for(j=0;j<=c;j++) { scanf("%d",&a[i][j]); } } for(i=0;i<=r;i++) { for(j=0;j<=c;j++) { if(ret[i][j]==-1) { dfs(i,j); } } } for(i=0;i<=r;i++) { for(j=0;j<=c;j++) { if(max<=ret[i][j]) max=ret[i][j]; } } max++; printf("%d",max); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator