Untitled

 avatar
ducsieumanh1hitlanamguku
plain_text
9 days ago
750 B
3
Indexable
Never
#include<bits/stdc++.h>
using namespace std;
int m,n;
bool a[405][405];

int main() {
    cin>>m>>n;
    for (int i=1;i<=m;i++) {
    	for (int j=1;j<=n;j++) {
    		cin>>a[i][j];
		}
	}
	for (int i=1;i<=m;i++) {
    	for (int j=1;j<=n;j++) {
    		int minimum=-1;
    		int axe=0;
    		for (int x=j;x<=n;x++) {
    			if (a[i][x]==1) break;
    			else minimum=x-j+1;
			}
			if (minimum==-1) {
				cout<<0<<" ";
			} else {
				int realmin=INT_MAX;
				for (int x=j;x<=j+minimum-1;x++) {
					int maxx=i;
					while (maxx<=m&&a[maxx][x]==0) {
						maxx++;
					}
					if (maxx>i&&realmin>maxx-i) {
						realmin=maxx-i;
					}
				}
				axe=(realmin*minimum);
				cout<<axe<<" ";
			}
		}
		cout<<endl;
	}
}
Leave a Comment