# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
833199 | vjudge1 | Bomb (IZhO17_bomb) | C++17 | 30 ms | 25084 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const int MAXN = 2500 + 10;
const int INF = INT_MAX;
const long long LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
int a[MAXN][MAXN];
ll row[MAXN], column[MAXN];
void solv(){
ll n, m;
cin >> n >> m;
for(int i = 0; i < n; i++){
string s;
cin >> s;
for(int j = 0; j < m; j++){
a[i][j] = (s[j] == '1' ? 1 : 0);
// a[i][j] = 1;
// cerr << a[i][j];
}
// cerr << endl;
}
ll mxrow = INF, mxcolumn = INF;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(a[i][j] == 1){
row[i]++;
column[j]++;
}else{
if(row[i] != 0)mxrow = min(mxrow, row[i]);
if(column[j] != 0)mxcolumn = min(mxcolumn, column[j]);
row[i] = 0;
column[j] = 0;
}
}
if(row[i] != 0)mxrow = min(mxrow, row[i]);
}
for(int i = 0; i < m; i++){
if(column[i] != 0){
mxcolumn = min(mxcolumn, column[i]);
}
}
if(mxrow == INF && mxcolumn == INF){
cout << n*m << endl;
return;
}
ll ans = mxrow * mxcolumn;
cout << ans << endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tc = 1;
// cin >> tc;
while(tc--)solv();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |