Submission #171589

# Submission time Handle Problem Language Result Execution time Memory
171589 2019-12-29T10:21:28 Z mcdx9524 Bomb (IZhO17_bomb) C++14
32 / 100
1000 ms 13564 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 2500 + 7;

char a[N][N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    if (n == 1 || m == 1) {
        vector <int> aa;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                char x;
                cin >> x;
                aa.push_back(x - '0');
            }
        }
        int cnt = 1;
        int res = 1e9;
        for (int i = 1; i < max(n, m); i++) {
            if (aa[i] != aa[i - 1]) {
                if (aa[i - 1] == 1) {
                    res = min(res, cnt);
                }
                cnt = 0;
            }
            cnt++;
        }
        if (aa[max(n, m) - 1] == 1) {
            res = min(res, cnt);
        }
        cout << res << '\n';
        return 0;
    }
    if (max(n, m) > 100) {
        //assert(0);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for (int x = 1; x <= n; x++) {
        for (int y = 1; y <= m; y++) {
            char b[n + 7][m + 7];
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    b[i][j] = a[i][j];
                }
            }
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    if (i + x - 1 > n || j + y - 1 > m) {
                        continue;
                    }
                    bool bad = false;
                    for (int r = i; r <= i + x - 1; r++) {
                        for (int c = j; c <= j + y - 1; c++) {
                            if (b[r][c] == '0') {
                                bad = true;
                            }
                            if (bad) break;
                        }
                        if (bad) break;
                    }
                    if (bad) continue;
                    for (int r = i; r <= i + x - 1; r++) {
                        for (int c = j; c <= j + y - 1; c++) {
                            b[r][c] = '2';
                        }
                    }
                }
            }
            bool good = true;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    if (a[i][j] == '0') {
                        continue;
                    }
                    if (a[i][j] == '1' && b[i][j] == '2') {
                        continue;
                    }
                    good = false;
                    if (!good) break;
                }
                if (!good) break;
            }
            if (good) {
                ans = max(ans, x * y);
            } else {
                break;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 404 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 296 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 4 ms 504 KB Output is correct
18 Correct 3 ms 504 KB Output is correct
19 Correct 8 ms 632 KB Output is correct
20 Correct 9 ms 632 KB Output is correct
21 Correct 3 ms 504 KB Output is correct
22 Correct 5 ms 504 KB Output is correct
23 Correct 43 ms 632 KB Output is correct
24 Correct 8 ms 504 KB Output is correct
25 Correct 35 ms 632 KB Output is correct
26 Correct 139 ms 636 KB Output is correct
27 Execution timed out 1074 ms 1272 KB Time limit exceeded
28 Correct 103 ms 1272 KB Output is correct
29 Execution timed out 1081 ms 1528 KB Time limit exceeded
30 Execution timed out 1069 ms 1784 KB Time limit exceeded
31 Execution timed out 1083 ms 1468 KB Time limit exceeded
32 Execution timed out 1084 ms 1656 KB Time limit exceeded
33 Execution timed out 1081 ms 1784 KB Time limit exceeded
34 Correct 108 ms 1400 KB Output is correct
35 Correct 704 ms 1912 KB Output is correct
36 Execution timed out 1061 ms 1784 KB Time limit exceeded
37 Correct 2 ms 376 KB Output is correct
38 Execution timed out 1074 ms 13148 KB Time limit exceeded
39 Correct 3 ms 376 KB Output is correct
40 Execution timed out 1082 ms 3704 KB Time limit exceeded
41 Correct 3 ms 376 KB Output is correct
42 Execution timed out 1082 ms 632 KB Time limit exceeded
43 Execution timed out 1079 ms 13176 KB Time limit exceeded
44 Execution timed out 1070 ms 1784 KB Time limit exceeded
45 Execution timed out 1076 ms 13176 KB Time limit exceeded
46 Execution timed out 1076 ms 13048 KB Time limit exceeded
47 Execution timed out 1077 ms 13048 KB Time limit exceeded
48 Execution timed out 1082 ms 13076 KB Time limit exceeded
49 Execution timed out 1066 ms 13048 KB Time limit exceeded
50 Execution timed out 1071 ms 13268 KB Time limit exceeded
51 Execution timed out 1081 ms 13048 KB Time limit exceeded
52 Execution timed out 1079 ms 13048 KB Time limit exceeded
53 Execution timed out 1087 ms 13048 KB Time limit exceeded
54 Execution timed out 1079 ms 13056 KB Time limit exceeded
55 Execution timed out 1071 ms 13176 KB Time limit exceeded
56 Execution timed out 1073 ms 13048 KB Time limit exceeded
57 Execution timed out 1078 ms 13176 KB Time limit exceeded
58 Execution timed out 1084 ms 13048 KB Time limit exceeded
59 Execution timed out 1077 ms 13048 KB Time limit exceeded
60 Execution timed out 1086 ms 13048 KB Time limit exceeded
61 Execution timed out 1076 ms 13108 KB Time limit exceeded
62 Execution timed out 1085 ms 13176 KB Time limit exceeded
63 Execution timed out 1083 ms 13180 KB Time limit exceeded
64 Execution timed out 1075 ms 13176 KB Time limit exceeded
65 Execution timed out 1086 ms 13048 KB Time limit exceeded
66 Execution timed out 1080 ms 13176 KB Time limit exceeded
67 Execution timed out 1071 ms 13244 KB Time limit exceeded
68 Execution timed out 1061 ms 13148 KB Time limit exceeded
69 Execution timed out 1082 ms 13176 KB Time limit exceeded
70 Execution timed out 1075 ms 9720 KB Time limit exceeded
71 Execution timed out 1078 ms 13176 KB Time limit exceeded
72 Execution timed out 1060 ms 13176 KB Time limit exceeded
73 Execution timed out 1079 ms 13432 KB Time limit exceeded
74 Execution timed out 1084 ms 13432 KB Time limit exceeded
75 Execution timed out 1082 ms 13304 KB Time limit exceeded
76 Execution timed out 1063 ms 13320 KB Time limit exceeded
77 Execution timed out 1086 ms 13304 KB Time limit exceeded
78 Execution timed out 1083 ms 13304 KB Time limit exceeded
79 Execution timed out 1083 ms 13304 KB Time limit exceeded
80 Execution timed out 1072 ms 13472 KB Time limit exceeded
81 Execution timed out 1090 ms 13432 KB Time limit exceeded
82 Execution timed out 1088 ms 13432 KB Time limit exceeded
83 Execution timed out 1068 ms 13304 KB Time limit exceeded
84 Execution timed out 1088 ms 13308 KB Time limit exceeded
85 Execution timed out 1076 ms 13432 KB Time limit exceeded
86 Execution timed out 1082 ms 13428 KB Time limit exceeded
87 Execution timed out 1087 ms 13484 KB Time limit exceeded
88 Execution timed out 1088 ms 13560 KB Time limit exceeded
89 Execution timed out 1079 ms 13492 KB Time limit exceeded
90 Execution timed out 1090 ms 10104 KB Time limit exceeded
91 Execution timed out 1075 ms 13432 KB Time limit exceeded
92 Execution timed out 1073 ms 13560 KB Time limit exceeded
93 Execution timed out 1072 ms 13480 KB Time limit exceeded
94 Execution timed out 1052 ms 13564 KB Time limit exceeded
95 Execution timed out 1074 ms 13564 KB Time limit exceeded
96 Execution timed out 1090 ms 13432 KB Time limit exceeded
97 Execution timed out 1074 ms 13560 KB Time limit exceeded
98 Execution timed out 1084 ms 13432 KB Time limit exceeded
99 Execution timed out 1079 ms 13432 KB Time limit exceeded
100 Execution timed out 1070 ms 13516 KB Time limit exceeded