Submission #1036549

# Submission time Handle Problem Language Result Execution time Memory
1036549 2024-07-27T13:47:36 Z adaawf Bomb (IZhO17_bomb) C++17
100 / 100
118 ms 55640 KB
#include <iostream>
using namespace std;
char a[2505][2505];
int f[2505][2505], g[2505][2505], d[2505];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            d[j] = n;
            cin >> a[i][j];
            if (a[i][j] == '1') f[i][j] = f[i - 1][j] + 1;
            else f[i][j] = 0;
        }
    }
    for (int i = n; i >= 1; i--) {
        for (int j = 1; j <= m; j++) {
            if (a[i][j] == '1') g[i][j] = g[i + 1][j] + 1;
            else g[i][j] = 0;
            if (a[i][j] == '1') {
                d[1] = min(d[1], f[i][j] + g[i][j] - 1);
            }
        }
    }
    int ma = m;
    for (int i = 1; i <= n; i++) {
        int h = n, k = n, c = 0;
        for (int j = 1; j <= m; j++) {
            if (a[i][j] == '1') {
                c++;
                h = min(h, f[i][j]);
                k = min(k, g[i][j]);
                d[c] = min(d[c], h + k - 1);
            }
            else {
                if (c != 0) ma = min(ma, c);
                c = 0;
                h = k = n;
            }
        }
        if (c != 0) ma = min(ma, c);
        h = k = n;
        c = 0;
        for (int j = m; j >= 1; j--) {
            if (a[i][j] == '1') {
                c++;
                h = min(h, f[i][j]);
                k = min(k, g[i][j]);
                d[c] = min(d[c], h + k - 1);
            }
            else {
                if (c != 0) ma = min(ma, c);
                c = 0;
                h = k = n;
            }
        }
        if (c != 0) ma = min(ma, c);
    }
    int res = -1e9;
    d[0] = 1e9;
    for (int i = 1; i <= ma; i++) {
        d[i] = min(d[i], d[i - 1]);
        res = max(res, i * d[i]);
    }
    cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 6 ms 38628 KB Output is correct
4 Correct 7 ms 39768 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 0 ms 4444 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 0 ms 2652 KB Output is correct
17 Correct 1 ms 8540 KB Output is correct
18 Correct 1 ms 6748 KB Output is correct
19 Correct 1 ms 6744 KB Output is correct
20 Correct 1 ms 7000 KB Output is correct
21 Correct 1 ms 8540 KB Output is correct
22 Correct 1 ms 8540 KB Output is correct
23 Correct 1 ms 6748 KB Output is correct
24 Correct 1 ms 6748 KB Output is correct
25 Correct 1 ms 6748 KB Output is correct
26 Correct 1 ms 4956 KB Output is correct
27 Correct 2 ms 11100 KB Output is correct
28 Correct 3 ms 12892 KB Output is correct
29 Correct 3 ms 14680 KB Output is correct
30 Correct 3 ms 12892 KB Output is correct
31 Correct 3 ms 12908 KB Output is correct
32 Correct 3 ms 12892 KB Output is correct
33 Correct 4 ms 16984 KB Output is correct
34 Correct 4 ms 14684 KB Output is correct
35 Correct 4 ms 16988 KB Output is correct
36 Correct 4 ms 14940 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 87 ms 55628 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 11 ms 23388 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 7004 KB Output is correct
43 Correct 86 ms 55516 KB Output is correct
44 Correct 4 ms 16984 KB Output is correct
45 Correct 83 ms 55528 KB Output is correct
46 Correct 89 ms 55636 KB Output is correct
47 Correct 98 ms 55556 KB Output is correct
48 Correct 80 ms 55500 KB Output is correct
49 Correct 80 ms 55640 KB Output is correct
50 Correct 85 ms 55480 KB Output is correct
51 Correct 78 ms 55632 KB Output is correct
52 Correct 79 ms 55632 KB Output is correct
53 Correct 78 ms 55548 KB Output is correct
54 Correct 108 ms 55544 KB Output is correct
55 Correct 118 ms 55636 KB Output is correct
56 Correct 102 ms 55492 KB Output is correct
57 Correct 76 ms 55632 KB Output is correct
58 Correct 80 ms 55528 KB Output is correct
59 Correct 76 ms 55636 KB Output is correct
60 Correct 78 ms 55632 KB Output is correct
61 Correct 85 ms 55492 KB Output is correct
62 Correct 82 ms 55636 KB Output is correct
63 Correct 86 ms 55636 KB Output is correct
64 Correct 78 ms 55508 KB Output is correct
65 Correct 113 ms 55528 KB Output is correct
66 Correct 99 ms 55632 KB Output is correct
67 Correct 85 ms 55536 KB Output is correct
68 Correct 92 ms 55548 KB Output is correct
69 Correct 75 ms 55632 KB Output is correct
70 Correct 50 ms 48464 KB Output is correct
71 Correct 82 ms 55488 KB Output is correct
72 Correct 74 ms 55632 KB Output is correct
73 Correct 81 ms 55632 KB Output is correct
74 Correct 74 ms 55492 KB Output is correct
75 Correct 75 ms 55488 KB Output is correct
76 Correct 75 ms 55632 KB Output is correct
77 Correct 77 ms 55440 KB Output is correct
78 Correct 74 ms 55520 KB Output is correct
79 Correct 71 ms 55520 KB Output is correct
80 Correct 89 ms 55476 KB Output is correct
81 Correct 72 ms 55632 KB Output is correct
82 Correct 80 ms 55632 KB Output is correct
83 Correct 78 ms 55448 KB Output is correct
84 Correct 72 ms 55636 KB Output is correct
85 Correct 84 ms 55632 KB Output is correct
86 Correct 81 ms 55636 KB Output is correct
87 Correct 97 ms 55636 KB Output is correct
88 Correct 78 ms 55508 KB Output is correct
89 Correct 85 ms 55504 KB Output is correct
90 Correct 50 ms 48468 KB Output is correct
91 Correct 77 ms 55632 KB Output is correct
92 Correct 80 ms 55632 KB Output is correct
93 Correct 76 ms 55632 KB Output is correct
94 Correct 76 ms 55632 KB Output is correct
95 Correct 73 ms 55492 KB Output is correct
96 Correct 83 ms 55492 KB Output is correct
97 Correct 101 ms 55636 KB Output is correct
98 Correct 75 ms 55632 KB Output is correct
99 Correct 78 ms 55572 KB Output is correct
100 Correct 82 ms 55500 KB Output is correct