1 solutions

  • 1
    @ 2025-4-23 19:37:14
    #include<bits/stdc++.h>
    using namespace std;
    const int N=110;
    char g[N][N];
    int sum[N][N]; 
    int main()
    {
    	int n,m,k;
    	cin>>n>>m>>k;
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=1;j<=m;j++)
    		{
    			char c;
    			cin>>c;
    			int t=c-'0';
    			//cout<<t<<" ????";
    			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+t;
    			//cout<<sum[i][j]<<" ";
    		}	
    		//cout<<endl;
    	} 
    	/*
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=1;j<=m;j++)
    		{
    			cout<<sum[i][j]<<" ";
    		}
    		cout<<endl;
    	}
    	*/
    	int res=1000000;
    	for(int x1=1;x1<=n;x1++)
    	{
    		for(int y1=1;y1<=m;y1++)
    		{
    			for(int x2=x1;x2<=n;x2++)
    			{
    				for(int y2=y1;y2<=m;y2++)
    				{
    					int t=sum[x2][y2]-sum[x2][y1-1]-sum[x1-1][y2]+sum[x1-1][y1-1];	
    					//printf("%d-----%d,%d---%d,%d\n",t,x1,y1,x2,y2); 
    					if(t>=k)	
    					{
    						res=min(res,(x2-x1+1)*(y2-y1+1));
    					}
    				}
    			}
    		}
    	}
    	if(res==1000000) res=0;
    	cout<<res;
    	return 0;
    }
    
    
    • 1

    Information

    ID
    2185
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    10
    Tags
    # Submissions
    9
    Accepted
    2
    Uploaded By