1 条题解

  • 2
    @ 2021-11-28 18:17:19
    /*****************************************
    备注:
    ******************************************/
    #include <queue>
    #include <math.h>
    #include <stack>
    #include <stdio.h>
    #include <iostream>
    #include <vector>
    #include <iomanip>
    #include <string.h>
    #include <algorithm>
    using namespace std;
    #define LL long long
    const int N = 1e5 + 10;
    const int INF = 0x3f3f3f3f;
    int a[1010][1011];
    int vis[1010][1010];
    int dx[] = {1,-1,0,0};
    int dy[] = {0,0,1,-1};
    int n,m;
    int dfs(int x ,int y )
    {
    	if(vis[x][y])
    		return vis[x][y];
    	int ans =1;
    	for(int i = 0 ; i < 4 ; i++)
    	{
    		int xx = x + dx[i];
    		int yy = y + dy[i];
    		if(xx < 0 || yy < 0 || xx >= n || yy >= m || a[x][y] <= a[xx][yy])
    			continue;
    		ans = max(dfs(xx,yy)+1 , ans);
    	}
    	vis[x][y] = ans;
    	return ans;
    }
    int main()
    {
    	cin >> n >> m;
    	for(int i = 0 ;i  < n ; i++)
    		for(int j = 0 ; j < m ; j ++)
    			scanf("%d",&a[i][j]);
    	int ans = 0;
    	for(int i = 0 ; i < n ; i++)
    		for(int j = 0 ; j < m ; j++)
    		{
    			int maxx = dfs(i,j);
    			ans = max(ans , maxx);
    		}
    	cout << ans << endl;
    	return 0;
    }
    
    • 1

    信息

    ID
    1295
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    递交数
    257
    已通过
    84
    上传者