???玄学代码随机AC???
查看原帖
???玄学代码随机AC???
304524
崔化博楼主2021/3/13 08:02
#include <iostream>
#include <climits>
#include <cstdio>
#include <algorithm>
using namespace std;
int r,c,a[105][105]={INT_MAX},maxx,f[105][105];
int xy[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
int dfs(int x,int y){
	if(f[x][y])
		return f[x][y];
	f[x][y]=1;
	for(int i=0;i<4;++i){
		int dx=x+xy[i][0],dy=y+xy[i][1];
		if(a[x][y]>a[dx][dy])
			f[x][y]=max(dfs(dx,dy)+1,f[x][y]);
	}
	return f[x][y];	
}
int main()
{
	scanf("%d%d",&r,&c);
	for(int i=1;i<=r;++i)
		for(int j=1;j<=c;++j)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=r;++i){
		for(int j=1;j<=c;++j){
			maxx=max(dfs(i,j),maxx);
		}
	}
	printf("%d",maxx-1);
	return 0;
} 
2021/3/13 08:02
加载中...