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 <iostream> using namespace std; long a[101][101]={-30000},f[101][101]={0}; long ans; long max(long a,long b){ if (a>b) return a; return b; } long DFS(long x,long y){ long t=0; if (f[x][y]!=0) return f[x][y]; if (a[x][y]<a[x-1][y]) t=max(DFS(x-1,y),t); if (a[x][y]<a[x+1][y]) t=max(DFS(x+1,y),t); if (a[x][y]<a[x][y+1]) t=max(DFS(x,y+1),t); if (a[x][y]<a[x][y-1]) t=max(DFS(x,y-1),t); f[x][y]=t+1; return f[x][y]; } int main(){ long ans=0; long m,n; scanf("%d%d",&m,&n); for (long i=1; i<=m; i++) for (long j=1; j<=n; j++) scanf("%d",&a[i][j]); for (long i=1; i<=m; i++) for (long j=1; j<=n; j++) ans=max(DFS(i,j),ans); printf("%d",ans); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator