제출 #145505

#제출 시각아이디문제언어결과실행 시간메모리
145505MladenPBomb (IZhO17_bomb)C++17
24 / 100
112 ms18936 KiB
#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mid (l+r)/2
#define endl '\n'
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000LL
#define INF 1000000000
#define EPS 1e-9
using namespace std;
string s[2510];
int N, M;
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0);
    cin >> N >> M;
    s[0] = string(M+2, '0');
    for(int i = 1; i <= N; i++) {
        cin >> s[i];
        s[i] = '0' + s[i] + '0';
    }
    s[N+1] = string(M+2, '0');
    int cur = 0, najmX = INF, najmY = INF;
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= M+1; j++) {
            if(s[i][j] == '1') cur++;
            if(s[i][j] == '0' && s[i][j-1] == '1') najmX = min(najmX, cur);
            if(s[i][j] == '0') cur = 0;
        }
    }
    cur = 0;
    for(int j = 1; j <= M; j++) {
        for(int i = 1; i <= N+1; i++) {
            if(s[i][j] == '1') cur++;
            if(s[i][j] == '0' && s[i-1][j] == '1') najmY = min(najmY, cur);
            if(s[i][j] == '0') cur = 0;
        }
    }
    cout << najmX*najmY;

}
#Verdict Execution timeMemoryGrader output
Fetching results...