답안 #1011302

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1011302 2024-06-30T10:02:32 Z LucaIlie Bomb (IZhO17_bomb) C++17
100 / 100
284 ms 74068 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);
    }

    int maxWidth = m;
    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 );
                maxHeight[1] = min( maxHeight[1], up[l][c] + down[l][c] - 1 );
            } else {
                if ( cons1 > 0 )
                    maxWidth = min( maxWidth, cons1 );
                cons1 = 0, hup = n, hdown = n;
            }
        }
        if ( cons1 > 0 )
            maxWidth = min( maxWidth, cons1 );
    }
    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 <= maxWidth; i++ ) {
        maxHeight[i] = min( maxHeight[i], maxHeight[i - 1] );
        maxArea = max( maxArea, maxHeight[i] * i );
    }
    cout << maxArea;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 10 ms 30556 KB Output is correct
4 Correct 9 ms 30368 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 0 ms 604 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 0 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1628 KB Output is correct
20 Correct 2 ms 1624 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1372 KB Output is correct
23 Correct 1 ms 1628 KB Output is correct
24 Correct 1 ms 1372 KB Output is correct
25 Correct 1 ms 1628 KB Output is correct
26 Correct 1 ms 1628 KB Output is correct
27 Correct 4 ms 4728 KB Output is correct
28 Correct 5 ms 5212 KB Output is correct
29 Correct 9 ms 6616 KB Output is correct
30 Correct 8 ms 7772 KB Output is correct
31 Correct 7 ms 6236 KB Output is correct
32 Correct 9 ms 7032 KB Output is correct
33 Correct 9 ms 8124 KB Output is correct
34 Correct 4 ms 5468 KB Output is correct
35 Correct 8 ms 8028 KB Output is correct
36 Correct 9 ms 8128 KB Output is correct
37 Correct 0 ms 604 KB Output is correct
38 Correct 224 ms 73640 KB Output is correct
39 Correct 1 ms 604 KB Output is correct
40 Correct 37 ms 19944 KB Output is correct
41 Correct 1 ms 600 KB Output is correct
42 Correct 2 ms 1628 KB Output is correct
43 Correct 209 ms 73820 KB Output is correct
44 Correct 9 ms 8028 KB Output is correct
45 Correct 241 ms 73756 KB Output is correct
46 Correct 202 ms 73736 KB Output is correct
47 Correct 204 ms 73848 KB Output is correct
48 Correct 203 ms 73808 KB Output is correct
49 Correct 200 ms 73808 KB Output is correct
50 Correct 199 ms 73880 KB Output is correct
51 Correct 223 ms 73808 KB Output is correct
52 Correct 209 ms 73860 KB Output is correct
53 Correct 216 ms 73808 KB Output is correct
54 Correct 207 ms 73808 KB Output is correct
55 Correct 222 ms 73812 KB Output is correct
56 Correct 256 ms 73812 KB Output is correct
57 Correct 211 ms 73812 KB Output is correct
58 Correct 251 ms 73808 KB Output is correct
59 Correct 231 ms 73864 KB Output is correct
60 Correct 210 ms 73684 KB Output is correct
61 Correct 262 ms 73808 KB Output is correct
62 Correct 212 ms 73792 KB Output is correct
63 Correct 215 ms 73696 KB Output is correct
64 Correct 232 ms 73808 KB Output is correct
65 Correct 216 ms 73872 KB Output is correct
66 Correct 211 ms 73808 KB Output is correct
67 Correct 230 ms 74068 KB Output is correct
68 Correct 220 ms 73740 KB Output is correct
69 Correct 265 ms 73812 KB Output is correct
70 Correct 136 ms 58968 KB Output is correct
71 Correct 205 ms 73732 KB Output is correct
72 Correct 222 ms 73816 KB Output is correct
73 Correct 217 ms 73764 KB Output is correct
74 Correct 214 ms 73852 KB Output is correct
75 Correct 224 ms 73808 KB Output is correct
76 Correct 219 ms 73812 KB Output is correct
77 Correct 284 ms 73812 KB Output is correct
78 Correct 228 ms 73808 KB Output is correct
79 Correct 200 ms 73796 KB Output is correct
80 Correct 206 ms 73808 KB Output is correct
81 Correct 208 ms 73784 KB Output is correct
82 Correct 221 ms 73656 KB Output is correct
83 Correct 216 ms 73648 KB Output is correct
84 Correct 220 ms 73764 KB Output is correct
85 Correct 244 ms 73812 KB Output is correct
86 Correct 219 ms 73640 KB Output is correct
87 Correct 242 ms 74068 KB Output is correct
88 Correct 217 ms 73808 KB Output is correct
89 Correct 223 ms 73808 KB Output is correct
90 Correct 140 ms 58964 KB Output is correct
91 Correct 205 ms 73808 KB Output is correct
92 Correct 220 ms 73812 KB Output is correct
93 Correct 222 ms 73724 KB Output is correct
94 Correct 213 ms 73732 KB Output is correct
95 Correct 211 ms 73856 KB Output is correct
96 Correct 232 ms 73808 KB Output is correct
97 Correct 213 ms 73688 KB Output is correct
98 Correct 230 ms 73840 KB Output is correct
99 Correct 216 ms 73640 KB Output is correct
100 Correct 202 ms 73696 KB Output is correct