Submission #1160801

#TimeUsernameProblemLanguageResultExecution timeMemory
1160801MisterReaperBomb (IZhO17_bomb)C++20
24 / 100
19 ms7168 KiB
#include <bits/stdc++.h>

using i64 = long long;

#ifdef DEBUG 
    #include "/home/ahmetalp/Desktop/Workplace/debug.h"
#else
    #define debug(...) void(23)
#endif

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int N, M;
    std::cin >> N >> M;
    std::vector<std::string> A(N);
    for (int i = 0; i < N; ++i) {
        std::cin >> A[i];
    }

    int x = M, y = N;
    for (int r = 0; r < N; ++r) {
        for (int i = 0, j = 0; i < M; i = j) {
            if (A[r][i] == '0') {
                j++;
            } else {
                while (j < M && A[r][j] == '1') {
                    j++;
                }
                x = std::min(x, j - i);
            }
        }
    }
    for (int c = 0; c < M; ++c) {
        for (int i = 0, j = 0; i < N; i = j) {
            if (A[i][c] == '0') {
                j++;
            } else {
                while (j < N && A[j][c] == '1') {
                    j++;
                }
                y = std::min(y, j - i);
            }
        }
    }

    assert(x != 0 && y != 0);
    
    std::cout << x * y << '\n';

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