Submission #170218

#TimeUsernameProblemLanguageResultExecution timeMemory
170218andrewBomb (IZhO17_bomb)C++17
24 / 100
127 ms8100 KiB
#include <bits/stdc++.h>

#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#define fi first
#define se second
#define p_b push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define sset ordered_set
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()

using namespace std;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 2e6;
const ll inf = 3e18;
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());

template <typename T> void vout(T s){cout << s << endl;exit(0);}

char c[3001][3001];

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // LOCAL

    ll n, m;
    ll h, w;
    h = w = inf;
    cin >> n >> m;

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)cin >> c[i][j];

    for(int i = 1; i <= n; i++){
        ll kol = 0;
        for(int j = 1; j <= m; j++){
            if(c[i][j] == '0'){
                if(kol)h = min(h, kol);
                kol = 0;
            }else kol++;
        }
        if(kol)h = min(h, kol);
    }

    for(int j = 1; j <= m; j++){
        ll kol = 0;
        for(int i = 1; i <= n; i++){
            if(c[i][j] == '0'){
                if(kol)w = min(w, kol);
                kol = 0;
            }else kol++;
        }
        if(kol)w = min(w, kol);
    }

    cout << h * w << "\n";

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...