제출 #833167

#제출 시각아이디문제언어결과실행 시간메모리
833167vjudge1Bomb (IZhO17_bomb)C++17
12 / 100
62 ms24908 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;

const int MOD = 1000000007;
const int dx[] = {0, 0, 1, -1, 1, -1, -1, 1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define pob pop_back
#define mp make_pair

#define all(x) x.begin(),x.end()
#define lsort(x) sort(all(x))
#define gsort(x) sort(all(x), greater<>())
#define rev(x) reverse(all(x))
#define mset(x, y) memset(x, y, sizeof(x))

#define vin(x, y) for(int i = 0; i < y; i++){decltype(x)::value_type temp; cin >> temp; x.pb(temp);}
#define vout(x) for(auto i : x){cout << i << " ";} cout << endl;
#define decide(x) if(x){ cout << "YES" << endl; }else{ cout << "NO" << endl; }
#define test(x) cout << "..." << endl

template<typename T> void chmin(T& x, T y) {if(x > y) x = y;}
template<typename T> void chmax(T& x, T y) {if(x < y) x = y;}

void fastIO(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

}

int n, m;
int arr[2500][2500];

void solve(){

    //IO

    cin >> n >> m;

    for(int i = 0; i < n; i++){

        string temp;
        cin >> temp;
        for(int j = 0; j < m; j++) arr[i][j] = temp[j] - '0';

    }

    ll w = LLONG_MAX;
    ll l = LLONG_MAX;

    for(int i = 0; i < n; i++){

        ll curr = 0;

        for(int j = 0; j < m; j++){

            if(arr[i][j] == 1) curr++;
            else{
                if(curr > 0) chmin(w, curr);
                curr = 0;
            }

        }

    }

    for(int i = 0; i < m; i++){

        ll curr = 0;

        for(int j = 0; j < n; j++){

            if(arr[j][i] == 1) curr++;
            else{
                if(curr > 0) chmin(l, curr);
                curr = 0;
            }

        }
        
    }

    cout << w * l << endl;

}

int main(){

    fastIO();

    int t = 1;
    // cin >> t;
    while(t--) solve();

}
#Verdict Execution timeMemoryGrader output
Fetching results...