Submission #332773

#TimeUsernameProblemLanguageResultExecution timeMemory
332773Bill_00Bomb (IZhO17_bomb)C++14
24 / 100
424 ms6892 KiB
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;
char a[2501][2501];
int main(){
	//ios_base::sync_with_stdio(NULL);
	// cin.tie(NULL);
	// cout.tie(NULL);
	int n,m;
	cin >> n >>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin >> a[i][j];
		}
	}
	int l,r,width=m,length=n;
	for(int i=1;i<=n;i++){
		l=-1,r=-1;
		for(int j=1;j<=m;j++){
			if(a[i][j]=='0'){
				if(l!=-1){
					width=min(width,r-l+1);
				}
				l=-1;	
			} 
			else{
				if(l==-1){
					l=j;
				}
				r=j;
			}
		}
		if(l!=-1) width=min(width,r-l+1);	
	}
	for(int i=1;i<=m;i++){
		l=-1,r=-1;
		for(int j=1;j<=n;j++){
			if(a[j][i]=='0'){
				if(l!=-1){
					length=min(length,r-l+1);
				}
				l=-1;	
			} 
			else{
				if(l==-1){
					l=j;
				}
				r=j;
			}
		}	
		if(l!=-1) length=min(length,r-l+1);
	}
	cout << width*length;
}
#Verdict Execution timeMemoryGrader output
Fetching results...