Submission #1305362

#TimeUsernameProblemLanguageResultExecution timeMemory
1305362LucasLeBomb (IZhO17_bomb)C++20
24 / 100
66 ms24992 KiB
#include <bits/stdc++.h>

int N, M;
int a[2505][2505];
int width, height;

int main() {
    std::cin.tie(0)->sync_with_stdio(0);

    std::cin >> N >> M;
    for (int i = 1; i <= N; ++i) {
        std::string s; std::cin >> s;
        for (int j = 1; j <= M; ++j) {
            a[i][j] = (s[j - 1] == '1');
        }
    }

    width = M + 1, height = N + 1;

    for (int i = 1; i <= N; ++i) {
        for (int j = 1, cnt = 0; j <= M + 1; ++j) {
            if (a[i][j] == 1) {
                cnt++;
            } else {
                if (a[i][j - 1] == 1) width = std::min(width, cnt);
                cnt = 0;
            }
        }
    }

    for (int j = 1; j <= M; ++j) {
        for (int i = 1, cnt = 0; i <= N + 1; ++i) {
            if (a[i][j] == 1) {
                cnt++;
            } else {
                if (a[i - 1][j] == 1) height = std::min(height, cnt);
                cnt = 0;
            }
        }
    }

    if (height == N + 1) height = 0;
    std::cout << width * height << '\n';

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