1 条题解

  • 0
    @ 2025-9-28 12:24:05

    忘特判了

    黑白方块的翻版

    #include<bits/stdc++.h>
    using namespace std;
    int a[101][101];
    bool f(int x,int y,int c,int d){
    	for(int i=x;i<=c;i++){
    		for(int j=y;j<=d;j++){
    			if(a[i][j]==0) return 0;
    		}
    	}
    	return 1;
    }//不在解释
    int main(){
    	int n,m,maxx=-1e9;
    	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++){
    			for(int ii=i;ii<=n;ii++){
    				for(int jj=j;jj<=m;jj++){
    					if(f(i,j,ii,jj)){
    						maxx=max(maxx,(ii-i+1)*(jj-j+1));//不再解释
    					}
    				}
    			}
    		}
    	}
    	if(maxx<0) cout<<'0';//特判
    	else cout<<maxx;
    }

    信息

    ID
    1351
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    4
    已通过
    1
    上传者