3 条题解

  • 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;
    }
    
    • 0
      @ 2026-11-21 17:39:26

      #include<bits/stdc++.h> using namespace std; const int MAX=1<<11; char mp[MAX][MAX]; void dfs(int x,int y,int sz);

      int main(){ int n; cin>>n; memset(mp,' ',sizeof mp); dfs(0,0,n); int h=1<<n; for(int i=0;i<h;i++) { int last=0; for(int j=0;j<(1<<(n+1));j++) if(mp[i][j]!=' ') last=j; for(int j=0;j<=last;j++) cout<<mp[i][j]; cout<<endl; } return 0; }

      void dfs(int x,int y,int sz){ if(sz==1) { mp[x][y+1]='/'; mp[x][y+2]='\'; mp[x+1][y]='/'; mp[x+1][y+1]=''; mp[x+1][y+2]=''; mp[x+1][y+3]='\'; return; } int half=1<<(sz-1); dfs(x,y+half,sz-1); dfs(x+half,y,sz-1); dfs(x+half,y+half*2,sz-1); }

      • 0
        @ 2025-7-23 9:30:20
        #include <bits/stdc++.h>
        using namespace std;
        const int N=1e2+10;
        const int INF=0x3f3f3f3f;
        int m,n,ans;
        int a[N][N];
        int dx[]={0,0,1,-1};
        int dy[]={1,-1,0,0};
        void dfs(int x,int y,int len){
        	ans=max(ans,len);
        	for(int i=0;i<=3;i++){
        		int xx=x+dx[i];
        		int yy=y+dy[i];
        		if(xx>=1&&xx<=n&&yy>=1&&yy<=m&&a[x][y]>a[xx][yy]){
        			dfs(xx,yy,len+1);
        		}
        	}
        }
        int main(){
        	cin>>n>>m;
        	for(int i=1;i<=n;i++){
        		for(int j=1;j<=m;j++){
        			cin>>a[i][j];
        		}
        	}
        	for(int i=1;i<=n;i++){
        		for(int j=1;j<=m;j++){
        			dfs(i,j,1);
        		}
        	}
        	cout<<ans;
        	return 0;
        }
        
        
        • 1

        信息

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