2 条题解

  • 0
    @ 2026-1-28 14:56:49
    #include <iostream>
    using namespace std;
    int arr[15][15];
    int main() { //排兵布阵 [GESP202509 四级]
    	int n,m;
    	cin>>n>>m;
    	for(int i=1;i<=n;i++){
    		for(int j=1;j<=m;j++){
    			cin>>arr[i][j];
    		}
    	}
    	int x,y,x2,y2,maxcnt=0;
    	for(int x=1;x<=n;x++){
    		for(int y=1;y<=m;y++){
    			for(int x2=x;x2<=n;x2++){
    				for(int y2=y;y2<=m;y2++){
    					int cnt=0;
    					for(int i=x;i<=x2;i++){
    						for(int j=y;j<=y2;j++){
    							if(arr[i][j]==1)
    								cnt++;
    						}
    					}
    					if(cnt==(x2-x+1)*(y2-y+1)){
    						maxcnt=max(maxcnt,cnt);
    					}
    				}
    			}
    		}
    	}
    	cout<<maxcnt;
    	return 0;
    }
    
    
    • 0
      @ 2026-1-17 10:58:21

      • 1

      信息

      ID
      2041
      时间
      1000ms
      内存
      256MiB
      难度
      8
      标签
      (无)
      递交数
      13
      已通过
      6
      上传者