제출 #333920

#제출 시각아이디문제언어결과실행 시간메모리
333920amunduzbaevBomb (IZhO17_bomb)C++14
24 / 100
192 ms25108 KiB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long 
#define ld long double 
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define prc(n) fixed << setprecision(n)
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1);
const int inf = 1e9+7;
const int N = 2505;

int a[N][N];
int n, m;

void solve(){
	fastios
	cin>>n>>m;
	int mnr = inf, mnc = inf;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			char c;
			cin>>c;
			a[i][j] = (c - '0' ? 1:0);	
		}
		for(int j=0;j<m;j++){
			int l = j;
			while(a[i][l] == a[i][j] && a[i][j] && l<m) l++;
			mnr = min(mnr, (l - j == 0 ? inf : l - j));
			j = l;
		}
	}
	
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			int l = j;
			while(a[l][i] == a[j][i] && a[j][i] && l<n) l++;
			mnc = min(mnc, (l - j == 0 ? inf : l - j));
			j =  l;
		}
	}
	if(mnc < inf && mnr < inf) cout<<mnc * mnr<<"\n";
	else cout<<0<<"\n";
	return;
}


 
int main(){
	fastios
	int t = 1;
	//cin>>t;
	while(t--) solve();
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...