3 solutions

  • 0
    @ 2023-11-18 8:50:41
    #include <bits/stdc++.h>
    using namespace std;
    bool check(bool map[101][101],short x1,short y1,short x2,short y2){
    	for (short i=x1;i<=x2;i++){
    		for (short i1=y1;i1<=y2;i1++){
    			if (map[i][i1]==0){
    				return 0;
    			}
    		}
    	}
    	return 1;
    }
    bool find(short a,bool map[101][101],short n,short m){
    	for (short i=0;i<=n-a;i++){
    		for (short i1=0;i1<=m-a;i1++){
    			if (check(map,i,i1,i+a-1,i1+a-1)==1){
    				return 1;
    			}
    		}
    	}
    	return 0;
    }
    int main(){
    	short n,m;
    	bool map[101][101];
    	cin >> n >> m;
    	for (short i=0;i<n;i++){
    		for (short i1=0;i1<m;i1++){
    			cin >> map[i][i1];
    		}
    	}
    	for (short i=max(n,m);i>1;i--){
    		if (find(i,map,n,m)==1){
    			cout << i;
    			return 0;
    		}
    	}
    	cout << 1;
    	return 0;
    }
    

    Information

    ID
    383
    Time
    1000ms
    Memory
    125MiB
    Difficulty
    2
    Tags
    # Submissions
    8
    Accepted
    6
    Uploaded By