Submission #689578

# Submission time Handle Problem Language Result Execution time Memory
689578 2023-01-28T18:50:29 Z azimanov Bomb (IZhO17_bomb) C++17
24 / 100
184 ms 110820 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 2500 + 10;
bool a[N][N];
int l[N][N], u[N][N];
int r[N][N], d[N][N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            char ch;
            cin >> ch;
            a[i][j] = ch == '1';
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (a[i][j]) {
                l[i][j] = l[i][j - 1] + 1;
                u[i][j] = u[i - 1][j] + 1;
            }
        }
    }
    for (int i = n; i >= 1; i--) {
        for (int j = m; j >= 1; j--) {
            if (a[i][j]) {
                r[i][j] = r[i][j + 1] + 1;
                d[i][j] = d[i + 1][j] + 1;
            }
        }
    }
    int mx_h = n, mx_w = m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (a[i][j]) {
                mx_h = min(mx_h, u[i][j] + d[i][j] - 1);
                mx_w = min(mx_w, l[i][j] + r[i][j] - 1);
            }
        }
    }
    cout << mx_h * mx_w << "\n";

#ifdef LOCAL
    cout << "\nTime elapsed: " << double(clock()) / CLOCKS_PER_SEC << " s.\n";
#endif
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 21 ms 46512 KB Output is correct
4 Correct 25 ms 46540 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Incorrect 1 ms 580 KB Output isn't correct
9 Incorrect 1 ms 596 KB Output isn't correct
10 Incorrect 1 ms 596 KB Output isn't correct
11 Incorrect 1 ms 596 KB Output isn't correct
12 Incorrect 1 ms 596 KB Output isn't correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Incorrect 1 ms 580 KB Output isn't correct
16 Correct 1 ms 712 KB Output is correct
17 Correct 1 ms 1492 KB Output is correct
18 Incorrect 1 ms 1012 KB Output isn't correct
19 Incorrect 1 ms 1492 KB Output isn't correct
20 Incorrect 2 ms 1492 KB Output isn't correct
21 Incorrect 1 ms 724 KB Output isn't correct
22 Incorrect 1 ms 1104 KB Output isn't correct
23 Incorrect 1 ms 1492 KB Output isn't correct
24 Incorrect 1 ms 1492 KB Output isn't correct
25 Incorrect 1 ms 2132 KB Output isn't correct
26 Correct 1 ms 2260 KB Output is correct
27 Correct 5 ms 7124 KB Output is correct
28 Incorrect 3 ms 1912 KB Output isn't correct
29 Incorrect 7 ms 9180 KB Output isn't correct
30 Incorrect 7 ms 7136 KB Output isn't correct
31 Incorrect 5 ms 5076 KB Output isn't correct
32 Incorrect 6 ms 6900 KB Output isn't correct
33 Incorrect 8 ms 9228 KB Output isn't correct
34 Incorrect 3 ms 2260 KB Output isn't correct
35 Incorrect 5 ms 2652 KB Output isn't correct
36 Correct 11 ms 11988 KB Output is correct
37 Incorrect 1 ms 724 KB Output isn't correct
38 Correct 156 ms 110704 KB Output is correct
39 Incorrect 1 ms 724 KB Output isn't correct
40 Incorrect 28 ms 29260 KB Output isn't correct
41 Incorrect 1 ms 724 KB Output isn't correct
42 Incorrect 2 ms 2252 KB Output isn't correct
43 Correct 148 ms 102852 KB Output is correct
44 Incorrect 9 ms 10836 KB Output isn't correct
45 Incorrect 156 ms 105508 KB Output isn't correct
46 Correct 148 ms 110812 KB Output is correct
47 Incorrect 153 ms 105596 KB Output isn't correct
48 Incorrect 154 ms 110748 KB Output isn't correct
49 Correct 159 ms 110744 KB Output is correct
50 Incorrect 150 ms 110716 KB Output isn't correct
51 Incorrect 150 ms 110744 KB Output isn't correct
52 Incorrect 163 ms 110736 KB Output isn't correct
53 Incorrect 146 ms 109344 KB Output isn't correct
54 Incorrect 132 ms 84080 KB Output isn't correct
55 Incorrect 144 ms 80680 KB Output isn't correct
56 Correct 152 ms 110820 KB Output is correct
57 Incorrect 131 ms 70692 KB Output isn't correct
58 Incorrect 129 ms 80668 KB Output isn't correct
59 Incorrect 137 ms 74684 KB Output isn't correct
60 Correct 143 ms 94424 KB Output is correct
61 Correct 159 ms 110752 KB Output is correct
62 Correct 159 ms 110768 KB Output is correct
63 Correct 160 ms 110756 KB Output is correct
64 Correct 153 ms 76472 KB Output is correct
65 Incorrect 184 ms 108696 KB Output isn't correct
66 Incorrect 150 ms 102408 KB Output isn't correct
67 Incorrect 158 ms 110776 KB Output isn't correct
68 Incorrect 154 ms 110748 KB Output isn't correct
69 Incorrect 132 ms 69808 KB Output isn't correct
70 Incorrect 90 ms 29204 KB Output isn't correct
71 Incorrect 123 ms 55776 KB Output isn't correct
72 Incorrect 123 ms 66724 KB Output isn't correct
73 Incorrect 131 ms 67744 KB Output isn't correct
74 Incorrect 140 ms 70816 KB Output isn't correct
75 Incorrect 128 ms 74080 KB Output isn't correct
76 Incorrect 131 ms 76772 KB Output isn't correct
77 Incorrect 150 ms 77728 KB Output isn't correct
78 Incorrect 133 ms 78248 KB Output isn't correct
79 Incorrect 101 ms 23076 KB Output isn't correct
80 Incorrect 100 ms 25700 KB Output isn't correct
81 Incorrect 99 ms 26404 KB Output isn't correct
82 Incorrect 137 ms 83256 KB Output isn't correct
83 Incorrect 133 ms 83424 KB Output isn't correct
84 Incorrect 98 ms 13772 KB Output isn't correct
85 Incorrect 128 ms 81320 KB Output isn't correct
86 Incorrect 160 ms 108660 KB Output isn't correct
87 Incorrect 146 ms 79176 KB Output isn't correct
88 Incorrect 144 ms 80960 KB Output isn't correct
89 Incorrect 142 ms 98596 KB Output isn't correct
90 Incorrect 91 ms 57684 KB Output isn't correct
91 Incorrect 146 ms 88768 KB Output isn't correct
92 Incorrect 135 ms 92252 KB Output isn't correct
93 Incorrect 153 ms 106800 KB Output isn't correct
94 Incorrect 146 ms 95908 KB Output isn't correct
95 Incorrect 131 ms 83616 KB Output isn't correct
96 Incorrect 141 ms 82976 KB Output isn't correct
97 Incorrect 164 ms 108232 KB Output isn't correct
98 Incorrect 141 ms 82484 KB Output isn't correct
99 Incorrect 138 ms 95116 KB Output isn't correct
100 Incorrect 152 ms 105748 KB Output isn't correct