답안 #1036536

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1036536 2024-07-27T13:37:37 Z adaawf Bomb (IZhO17_bomb) C++17
90 / 100
94 ms 55888 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;
    for (int i = 1; i <= ma; i++) {
        res = max(res, i * d[i]);
    }
    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 5 ms 53128 KB Output is correct
4 Correct 6 ms 54364 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Incorrect 0 ms 2396 KB Output isn't correct
8 Correct 1 ms 4564 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 0 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 0 ms 4444 KB Output is correct
14 Correct 1 ms 4440 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 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 6748 KB Output is correct
20 Correct 1 ms 6748 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 Incorrect 1 ms 4956 KB Output isn't correct
27 Incorrect 2 ms 11100 KB Output isn't correct
28 Correct 2 ms 12892 KB Output is correct
29 Correct 3 ms 14684 KB Output is correct
30 Correct 3 ms 12864 KB Output is correct
31 Correct 3 ms 12892 KB Output is correct
32 Correct 3 ms 12892 KB Output is correct
33 Correct 4 ms 16988 KB Output is correct
34 Correct 2 ms 14684 KB Output is correct
35 Correct 4 ms 16988 KB Output is correct
36 Incorrect 4 ms 14940 KB Output isn't correct
37 Correct 1 ms 4528 KB Output is correct
38 Correct 81 ms 55516 KB Output is correct
39 Correct 1 ms 4440 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 77 ms 55636 KB Output is correct
44 Correct 4 ms 16984 KB Output is correct
45 Correct 75 ms 55552 KB Output is correct
46 Correct 78 ms 55632 KB Output is correct
47 Correct 82 ms 55888 KB Output is correct
48 Correct 76 ms 55636 KB Output is correct
49 Incorrect 77 ms 55508 KB Output isn't correct
50 Correct 73 ms 55636 KB Output is correct
51 Correct 75 ms 55636 KB Output is correct
52 Correct 84 ms 55556 KB Output is correct
53 Correct 77 ms 55540 KB Output is correct
54 Correct 74 ms 55460 KB Output is correct
55 Correct 71 ms 55636 KB Output is correct
56 Correct 86 ms 55636 KB Output is correct
57 Correct 73 ms 55536 KB Output is correct
58 Correct 71 ms 55632 KB Output is correct
59 Correct 75 ms 55632 KB Output is correct
60 Incorrect 78 ms 55632 KB Output isn't correct
61 Incorrect 76 ms 55632 KB Output isn't correct
62 Incorrect 79 ms 55648 KB Output isn't correct
63 Incorrect 80 ms 55632 KB Output isn't correct
64 Incorrect 73 ms 55644 KB Output isn't correct
65 Correct 72 ms 55632 KB Output is correct
66 Correct 77 ms 55632 KB Output is correct
67 Correct 75 ms 55548 KB Output is correct
68 Correct 76 ms 55596 KB Output is correct
69 Correct 72 ms 55636 KB Output is correct
70 Correct 45 ms 48468 KB Output is correct
71 Correct 69 ms 55636 KB Output is correct
72 Correct 75 ms 55528 KB Output is correct
73 Correct 72 ms 55528 KB Output is correct
74 Correct 71 ms 55632 KB Output is correct
75 Correct 71 ms 55632 KB Output is correct
76 Correct 72 ms 55636 KB Output is correct
77 Correct 94 ms 55632 KB Output is correct
78 Correct 93 ms 55492 KB Output is correct
79 Correct 72 ms 55396 KB Output is correct
80 Correct 73 ms 55632 KB Output is correct
81 Correct 94 ms 55636 KB Output is correct
82 Correct 74 ms 55524 KB Output is correct
83 Correct 75 ms 55636 KB Output is correct
84 Correct 70 ms 55636 KB Output is correct
85 Correct 85 ms 55636 KB Output is correct
86 Correct 77 ms 55636 KB Output is correct
87 Correct 76 ms 55564 KB Output is correct
88 Correct 71 ms 55632 KB Output is correct
89 Correct 74 ms 55636 KB Output is correct
90 Correct 52 ms 48464 KB Output is correct
91 Correct 72 ms 55644 KB Output is correct
92 Correct 94 ms 55636 KB Output is correct
93 Correct 75 ms 55632 KB Output is correct
94 Correct 73 ms 55636 KB Output is correct
95 Correct 72 ms 55632 KB Output is correct
96 Correct 71 ms 55636 KB Output is correct
97 Correct 79 ms 55436 KB Output is correct
98 Correct 93 ms 55500 KB Output is correct
99 Correct 72 ms 55632 KB Output is correct
100 Correct 75 ms 55636 KB Output is correct