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 |
为何re,求大神指点#include<iostream> using namespace std; int a[105][105],len[105][105]; int max(int a,int b,int c,int d) {if(a<b) a=b; if(a<c) a=c; if(a<d) a=d; return a;} int dfs(int p,int q,int h) {if(a[p][q]==0||a[p][q]>h) return 0; if(len[p][q]>=0) return len[p][q]; len[p][q]=max(dfs(p-1,q,a[p][q]),dfs(p,q+1,a[p][q]),dfs(p+1,q,a[p][q]),dfs(p,q-1,a[p][q]))+1; return len[p][q]; } int main() {int i,j,x,y,max; while(cin>>x>>y) {memset(a,0,sizeof(a)); memset(len,0,sizeof(len)); for(i=0;i<x;i++) for(j=0;j<y;j++) {cin>>a[i][j]; len[i][j]=-1;} max=0; for(i=0;i<x;i++) for(j=0;j<y;j++) {len[i][j]=dfs(i,j,a[i][j]); if(len[i][j]>max) max=len[i][j];} cout<<max<<endl;} return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator