Submission #833599

#TimeUsernameProblemLanguageResultExecution timeMemory
833599vjudge1Bomb (IZhO17_bomb)C++17
24 / 100
88 ms6504 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long, long long>
#define pii pair<int,int>
#define fi first
#define se second
const ll MOD=1e9+7;

int n, m;
ll shortRow=MOD, shortCol=MOD;
char arr[2501][2501];

void solve(){
    cin >> n >> m;
    for(int i=0; i<n; i++){
        bool counting=false;
        ll cnt=0;
        for(int j=0; j<m; j++){
            cin >> arr[i][j];
            if(arr[i][j]=='1'){
                counting=true;
                cnt++;
            }
            if(arr[i][j]!='1' && counting){
                counting=false;
                shortRow=min(shortRow,cnt);
                cnt=0;
            }
        }
        if(cnt!=0) shortRow=min(shortRow,cnt);
    }
    for(int i=0; i<m; i++){
        bool counting=false;
        ll cnt=0;
        for(int j=0; j<n; j++){
            if(arr[j][i]=='1'){
                counting=true;
                cnt++;
            }
            if(arr[j][i]!='1' && counting){
                counting=false;
                shortCol=min(shortCol,cnt);
                cnt=0;
            }
        }
        if(cnt!=0) shortCol=min(shortCol,cnt);
    }
    cout << shortCol*shortRow << endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int q=1;
    for(int i=0; i<q; i++){
        solve();
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...