#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;
#define forr(_a,_b,_c) for(int _a = (_b); _a <= int (_c); ++_a)
#define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> int (_c);)
#define forf(_a,_b,_c) for(int _a = (_b); _a < int (_c); ++_a)
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define mask(i) (1LL << (i))
#define bit(x, i) (((x) >> (i)) & 1)
#define bp __builtin_popcountll
#define file "test"
template<class X, class Y>
bool minz(X &x, const Y &y) {
if (x > y) {
x = y;
return true;
} return false;
}
template<class X, class Y>
bool maxz(X &x, const Y &y) {
if (x < y) {
x = y;
return true;
} return false;
}
const int N = 25e2 + 5;
const ll oo = (ll) 1e16;
const ll mod = 1e9 + 7; // 998244353;
int n, m, l[N][N], r[N][N], u[N][N], d[N][N];
string s[N];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
#endif
cin >> n >> m;
forr (i, 1, n){
cin >> s[i];
s[i] = '#' + s[i];
}
forr (i, 1, n){
int lst = 0;
forr (j, 1, m){
if (s[i][j] == '0')
lst = j;
else l[i][j] = lst;
}
lst = m + 1;
ford (j, m, 1){
if (s[i][j] == '0')
lst = j;
else r[i][j] = lst;
}
}
forr (j, 1, m){
int lst = 0;
forr (i, 1, n){
if (s[i][j] == '0')
lst = i;
else u[i][j] = lst;
}
lst = n + 1;
ford (i, n, 1){
if (s[i][j] == '0')
lst = i;
else d[i][j] = lst;
}
}
int h = n, w = m;
forr (i, 1, n){
forr (j, 1, m){
if (s[i][j] == '1'){
minz(h, d[i][j] - u[i][j] - 1);
minz(w, r[i][j] - l[i][j] - 1);
}
}
}
cout << w * h << "\n";
return 0;
}
/*
*/
컴파일 시 표준 에러 (stderr) 메시지
bomb.cpp: In function 'int main()':
bomb.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
48 | freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bomb.cpp:48:49: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
48 | freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |