1 solutions

  • 1
    @ 2024-5-5 14:11:05
    #include<bits/stdc++.h>
    using namespace std;
    const int N=35,M=35;
    int w[N][M];
    int main()
    {
    	int n,m;
    	cin>>n>>m;
    	for(int i=1;i<=n;i++) //获取原始矩阵 
    	{
    		for(int j=1;j<=m;j++)
    		{
    			cin>>w[i][j];
    		}
    	}
    	int maxv=0; //最大值 
    	for(int i=1;i<=n;i++) //右下角 
    	{
    		for(int j=1;j<=m;j++)
    		{
    			for(int x=i;x>=1;x--) //左上角 
    			{
    				for(int y=j;y>=1;y--)
    				{
    					int sum=0;
    					for(int a=i;a>=x;a--) //当前区域的和 
    					{
    						for(int b=j;b>=y;b--)
    						{
    							sum+=w[a][b];
    						}
    					}
    					if(sum==0) //全是空白区域 
    					{
    						int temp=(i-x+1)*(j-y+1); //计算面积 
    						if(temp>maxv)
    						{
    							maxv=temp;
    						}
    					}
    				}
    			}
    		}
    	}
    	cout<<maxv;
    	return 0;
    }
    
    • 1

    Information

    ID
    676
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    # Submissions
    43
    Accepted
    15
    Uploaded By