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<iostream> using namespace std; #define MAXN 20000 int map[105][105]; int f[105][105]; int x[]={0,0,1,-1}; int y[]={1,-1,0,0}; void dfs(int i,int j) { for(int k=0;k<4;k++) { if(map[i+x[k]][j+y[k]]>map[i][j] && f[i][j]+1>f[i+x[k]][j+y[k]]) { f[i+x[k]][j+y[k]]=f[i][j]+1; dfs(i+x[k],j+y[k]); } } } int main() { int r,c,s; while(cin>>r>>c) { for(int i=1;i<=r;i++) for(int j=1;j<=c;j++) cin>>map[i][j],f[i][j]=1; for(int i=0;i<=r+1;i++) map[0][i]=map[r+1][i]=map[i][0]=map[i][c+1]=MAXN; for(int i=1;i<=r;i++) for(int j=1;j<=c;j++) dfs(i,j); s=0; for(int i=1;i<=r;i++) for(int j=1;j<=c;j++) if(f[i][j]>s) s=f[i][j]; cout<<s<<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