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> #include<cstdio> #include<cstring> #include<string> #include<algorithm> using namespace std; int s[110][110]; int a[110][110]; int x[4]={0,0,1,-1}; int y[4]={-1,1,0,0}; int n,m; int dfs(int px,int py) { int i,tx,ty; for(i=0;i<4;i++) { tx=px+x[i]; ty=py+y[i]; if(tx>=0&&tx<n&&ty>=0&&ty<m) { if(s[tx][ty]>s[px][py]&&a[px][py]+1>a[tx][ty]) { a[tx][ty]=a[px][py]+1; dfs(tx,ty); } } } } int main() { int i,j,mpp,ki,kj; scanf("%d%d",&n,&m); for(i=0;i<n;i++) for(j=0;j<m;j++) { scanf("%d",&s[i][j]); a[i][j]=1; } for(i=0;i<n;i++) for(j=0;j<m;j++) dfs(i,j); mpp=0; for(i=0;i<n;i++) for(j=0;j<m;j++) if(mpp<a[i][j]) mpp=a[i][j]; printf("%d\n",mpp); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator