1 solutions

  • 0
    @ 2025-6-14 13:48:49
    #include<bits/stdc++.h>
    using namespace std;
    const int N=15;
    char g[N][N];
    int main()
    {
    	int n,m;
    	cin>>n>>m;
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=1;j<=m;j++)
    		{
    			cin>>g[i][j];	
    		} 
    	}
    	int res=0;
    	for(int x=1;x<=n;x++)
    	{
    		for(int y=1;y<=m;y++)
    		{
    			
    			for(int l=x;l<=n;l++)
    			{
    				for(int r=y;r<=m;r++)
    				{
    					int a=0,b=0;
    					for(int x1=x;x1<=l;x1++)
    					{
    						for(int y1=y;y1<=r;y1++)
    						{
    							if(g[x1][y1]=='0') a++;
    							else b++;
    						}
    					}
    					if(a==b)
    					{
    						res=max(res,(l-x+1)*(r-y+1));
    					}
    				}
    			}
    		}
    	}
    	cout<<res;
    	return 0;
    }
    
    
    • 1

    Information

    ID
    2183
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    10
    Tags
    # Submissions
    6
    Accepted
    3
    Uploaded By