Los Ski Valley p1434

woc spent 20 minutes pinched a memory search over again! ! ! ! ! I really recently that his wife was too lucky.

The questions were very simple, at any one entrance into it, playing a neatly record search, remember to look at the entrance can be sentenced if found other time after it already has its value, and even they do not search the search.

#include <iostream>
#include <cstdio>
using namespace std;

int n,m,f[101][101],a[101][101],ans,maxn;

int find(int x,int y){
	if(f[x][y]>0)	return f[x][y];
	if(x!=1&&a[x-1][y]<a[x][y])	f[x][y]=max(f[x][y],1+find(x-1,y));
	if(x!=n&&a[x+1][y]<a[x][y])	f[x][y]=max(f[x][y],1+find(x+1,y));
	if(y!=1&&a[x][y-1]<a[x][y])	f[x][y]=max(f[x][y],1+find(x,y-1));
	if(y!=m&&a[x][y+1]<a[x][y])	f[x][y]=max(f[x][y],1+find(x,y+1));
	return f[x][y];
}

int main () {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(f[i][j]==0)	ans=1+find(i,j);
			maxn = max (years maxn);
		}
	}
	printf("%d",maxn);
	return 0;
} 

 

Guess you like

Origin www.cnblogs.com/jindui/p/11094010.html