求助! #10过不去
查看原帖
求助! #10过不去
988775
s1mpfe楼主2024/12/19 07:44
#include <bits/stdc++.h>
using namespace std;
int a[1100][1100];
int dx[4]={0,0,1,-1};
int dy[4]={-1,1,0,0};
int r,c,i,j,k;
int tot=1;
int s[1100][1100];
int sc(int x,int y)
{
	if(s[x][y]!=0)
		return s[x][y];
	s[x][y]=1;
	for(k=0;k<4;k++)
	{
		int xx=x+dx[k];
		int yy=y+dy[k];
		if(xx>0 && yy>0 && xx<=r && yy<=c && a[xx][yy]<a[x][y])
		{
			sc(xx,yy);
			s[x][y]=max(s[xx][yy]+1,s[x][y]);
		}
	}
	return s[x][y];
}
int main()
{
	cin>>r>>c;
	for(i=1;i<=r;i++)
		for(j=1;j<=c;j++)
			cin>>a[i][j];
	for(i=1;i<=r;i++)
		for(j=1;j<=c;j++)
			tot=max(tot,sc(i,j));		
	cout<<tot<<endl;
	return 0;
}
2024/12/19 07:44
加载中...