Submission #1011295

# Submission time Handle Problem Language Result Execution time Memory
1011295 2024-06-30T09:51:01 Z LucaIlie Bomb (IZhO17_bomb) C++17
49 / 100
268 ms 80084 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2500;
int mat[MAX_N + 2][MAX_N + 2], up[MAX_N + 2][MAX_N + 2], down[MAX_N + 2][MAX_N + 2], hup[MAX_N + 2], hdown[MAX_N + 2], maxHeight[MAX_N + 2];

int main() {
    int n, m;

    cin >> n >> m;
    for ( int l = 1; l <= n; l++ ) {
        for ( int c = 1; c <= m; c++ ) {
            char ch;
            cin >> ch;
            mat[l][c] = ch - '0';
        }
    }

    for ( int l = 1; l <= n; l++ ) {
        for ( int c = 1; c <= m; c++ )
            up[l][c] = (mat[l][c] ? up[l - 1][c] + 1 : 0);
    }
    for ( int l = n; l >= 1; l-- ) {
        for ( int c = 1; c <= m; c++ )
            down[l][c] = (mat[l][c] ? down[l + 1][c] + 1 : 0);
    }

    for ( int i = 0; i <= m; i++ )
        maxHeight[i] = n;
    for ( int l = 1; l <= n; l++ ) {
        int cons1 = 0, hup = n, hdown = n;
        for ( int c = 1; c <= m; c++ ) {
            if ( mat[l][c] ) {
                cons1++;
                hup = min( hup, up[l][c] );
                hdown = min( hdown, down[l][c] );
                maxHeight[cons1] = min( maxHeight[cons1], hup + hdown - 1 );
            } else
                cons1 = 0, hup = n, hdown = n;
        }
    }
    for ( int l = 1; l <= n; l++ ) {
        int cons1 = 0, hup = n, hdown = n;
        for ( int c = m; c >= 1; c-- ) {
            if ( mat[l][c] ) {
                cons1++;
                hup = min( hup, up[l][c] );
                hdown = min( hdown, down[l][c] );
                maxHeight[cons1] = min( maxHeight[cons1], hup + hdown - 1 );
            } else
                cons1 = 0, hup = n, hdown = n;
        }
    }

    int maxArea = 0;
    for ( int i = 1; i <= n; i++ ) {
        maxHeight[i] = min( maxHeight[i], maxHeight[i - 1] );
        maxArea = max( maxArea, maxHeight[i] * i );
    }
    cout << maxArea;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 9 ms 30464 KB Output is correct
4 Correct 9 ms 30556 KB Output is correct
5 Incorrect 0 ms 352 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 0 ms 604 KB Output isn't correct
9 Incorrect 0 ms 604 KB Output isn't correct
10 Incorrect 0 ms 604 KB Output isn't correct
11 Incorrect 1 ms 604 KB Output isn't correct
12 Incorrect 0 ms 440 KB Output isn't correct
13 Incorrect 0 ms 604 KB Output isn't correct
14 Incorrect 0 ms 444 KB Output isn't correct
15 Incorrect 0 ms 608 KB Output isn't correct
16 Incorrect 0 ms 604 KB Output isn't correct
17 Incorrect 1 ms 1116 KB Output isn't correct
18 Incorrect 0 ms 1116 KB Output isn't correct
19 Incorrect 1 ms 1628 KB Output isn't correct
20 Incorrect 1 ms 1628 KB Output isn't correct
21 Incorrect 0 ms 1116 KB Output isn't correct
22 Incorrect 1 ms 1372 KB Output isn't correct
23 Correct 1 ms 1628 KB Output is correct
24 Incorrect 1 ms 1368 KB Output isn't correct
25 Incorrect 1 ms 1628 KB Output isn't correct
26 Incorrect 1 ms 1628 KB Output isn't correct
27 Incorrect 6 ms 4956 KB Output isn't correct
28 Incorrect 5 ms 5240 KB Output isn't correct
29 Incorrect 6 ms 6588 KB Output isn't correct
30 Incorrect 8 ms 8024 KB Output isn't correct
31 Correct 7 ms 6236 KB Output is correct
32 Incorrect 7 ms 7260 KB Output isn't correct
33 Correct 9 ms 8456 KB Output is correct
34 Incorrect 4 ms 5720 KB Output isn't correct
35 Incorrect 9 ms 8284 KB Output isn't correct
36 Incorrect 9 ms 8284 KB Output isn't correct
37 Incorrect 0 ms 604 KB Output isn't correct
38 Correct 213 ms 79852 KB Output is correct
39 Incorrect 0 ms 600 KB Output isn't correct
40 Incorrect 31 ms 20564 KB Output isn't correct
41 Correct 0 ms 600 KB Output is correct
42 Correct 1 ms 1628 KB Output is correct
43 Incorrect 222 ms 79952 KB Output isn't correct
44 Correct 12 ms 8284 KB Output is correct
45 Correct 205 ms 79956 KB Output is correct
46 Incorrect 213 ms 79812 KB Output isn't correct
47 Correct 213 ms 79956 KB Output is correct
48 Correct 233 ms 79976 KB Output is correct
49 Incorrect 229 ms 79956 KB Output isn't correct
50 Correct 268 ms 79956 KB Output is correct
51 Correct 222 ms 79952 KB Output is correct
52 Correct 219 ms 79852 KB Output is correct
53 Correct 214 ms 79956 KB Output is correct
54 Correct 213 ms 79868 KB Output is correct
55 Correct 213 ms 79956 KB Output is correct
56 Incorrect 220 ms 79952 KB Output isn't correct
57 Correct 208 ms 79956 KB Output is correct
58 Correct 210 ms 79784 KB Output is correct
59 Correct 221 ms 79920 KB Output is correct
60 Incorrect 206 ms 79844 KB Output isn't correct
61 Incorrect 206 ms 79992 KB Output isn't correct
62 Incorrect 217 ms 79948 KB Output isn't correct
63 Incorrect 213 ms 79988 KB Output isn't correct
64 Incorrect 202 ms 79752 KB Output isn't correct
65 Incorrect 200 ms 79840 KB Output isn't correct
66 Correct 218 ms 79964 KB Output is correct
67 Correct 206 ms 79956 KB Output is correct
68 Correct 198 ms 79952 KB Output is correct
69 Correct 226 ms 79760 KB Output is correct
70 Correct 138 ms 63056 KB Output is correct
71 Correct 219 ms 79956 KB Output is correct
72 Correct 204 ms 79932 KB Output is correct
73 Correct 204 ms 79916 KB Output is correct
74 Correct 232 ms 80084 KB Output is correct
75 Correct 192 ms 79952 KB Output is correct
76 Correct 193 ms 79812 KB Output is correct
77 Correct 205 ms 79956 KB Output is correct
78 Correct 204 ms 79808 KB Output is correct
79 Incorrect 226 ms 79956 KB Output isn't correct
80 Incorrect 214 ms 79956 KB Output isn't correct
81 Correct 245 ms 79864 KB Output is correct
82 Correct 231 ms 79944 KB Output is correct
83 Correct 216 ms 79952 KB Output is correct
84 Incorrect 226 ms 79964 KB Output isn't correct
85 Correct 225 ms 79972 KB Output is correct
86 Incorrect 239 ms 79976 KB Output isn't correct
87 Incorrect 231 ms 79836 KB Output isn't correct
88 Correct 226 ms 79952 KB Output is correct
89 Correct 233 ms 79800 KB Output is correct
90 Correct 155 ms 63068 KB Output is correct
91 Correct 231 ms 79956 KB Output is correct
92 Correct 227 ms 79956 KB Output is correct
93 Incorrect 218 ms 79952 KB Output isn't correct
94 Correct 223 ms 79916 KB Output is correct
95 Correct 251 ms 79892 KB Output is correct
96 Correct 194 ms 79952 KB Output is correct
97 Incorrect 204 ms 79952 KB Output isn't correct
98 Correct 210 ms 79952 KB Output is correct
99 Correct 220 ms 79956 KB Output is correct
100 Incorrect 218 ms 79960 KB Output isn't correct