Submission #682496

#TimeUsernameProblemLanguageResultExecution timeMemory
682496HamletPetrosyanBomb (IZhO17_bomb)C++17
24 / 100
408 ms6548 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 2505, INF = 1e9 + 5;

int n, m;
bool a[N][N], found = false;
int w = INF, h = INF;

int main(){
	cin >> n >> m;

	char x;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> x;
			a[i][j] = (x == '1');
			found = found || (x == '1');
		}
	}
	if(!found){
		cout << n * m << "\n";
		return 0;
	}
	int now = 0, np = INF;
	for(int i = 0; i < n; i++){
		now = 0;
		for(int j = 0; j < m; j++){
			if(!a[i][j]){
				if(now) np = min(np, now);
				now = 0;
			}
			else now++;
		}
		if(now) np = min(np, now);
	}
	w = np;
	np = INF;
	for(int i = 0; i < m; i++){
		now = 0;
		for(int j = 0; j < n; j++){
			if(!a[j][i]){
				if(now) np = min(np, now);
				now = 0;
			}
			else now++;
		}
		if(now) np = min(np, now);
	}
	h = np;
	cout << w * h << "\n";
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...