Submission #1118808

#TimeUsernameProblemLanguageResultExecution timeMemory
1118808Younis_DwaiBomb (IZhO17_bomb)C++14
24 / 100
131 ms12636 KiB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define int long long
#define in insert
#define mid (l+r)/2
#define in insert
using namespace std;
const int N=2505;
char b[N][N];
int n,m;
int32_t main(){
    ios::sync_with_stdio(false);cin.tie(nullptr);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>b[i][j];
        }
    }
    int h=n,w=m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(b[i][j]=='1'){
               int cnt=1;
               while(j+1<=m && b[i][j+1]=='1'){
                     ++cnt;
                     ++j;
               }
               w=min(w,cnt);
            }
        }
    }
    for(int j=1;j<=m;j++){
        for(int i=1;i<=n;i++){
            if(b[i][j]=='1'){
               int cnt=1;
               while(i+1<=n && b[i+1][j]=='1'){
                     ++i;
                     ++cnt;
               }
               h=min(h,cnt);
            }
        }
    }
    cout<<h*w;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...