답안 #171587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171587 2019-12-29T10:18:36 Z mcdx9524 Bomb (IZhO17_bomb) C++14
20 / 100
1000 ms 760 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 <= n; 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);
            }
        }
    }
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Incorrect 2 ms 376 KB Output isn't correct
11 Incorrect 3 ms 376 KB Output isn't correct
12 Correct 2 ms 376 KB Output is correct
13 Incorrect 2 ms 376 KB Output isn't correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 380 KB Output is correct
16 Correct 4 ms 376 KB Output is correct
17 Correct 74 ms 504 KB Output is correct
18 Incorrect 53 ms 504 KB Output isn't correct
19 Incorrect 200 ms 632 KB Output isn't correct
20 Incorrect 220 ms 632 KB Output isn't correct
21 Correct 55 ms 508 KB Output is correct
22 Correct 127 ms 636 KB Output is correct
23 Correct 708 ms 632 KB Output is correct
24 Incorrect 159 ms 504 KB Output isn't correct
25 Execution timed out 1043 ms 760 KB Time limit exceeded
26 Execution timed out 1078 ms 632 KB Time limit exceeded
27 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 3 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Correct 3 ms 376 KB Output is correct
38 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Correct 2 ms 376 KB Output is correct
40 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Correct 3 ms 376 KB Output is correct
42 Execution timed out 1081 ms 632 KB Time limit exceeded
43 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
44 Runtime error 16 ms 604 KB Execution killed with signal 11 (could be triggered by violating memory limits)
45 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
46 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
47 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
48 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
49 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
50 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
51 Runtime error 3 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
52 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
54 Runtime error 3 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
55 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
56 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
57 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
58 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
59 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
60 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
61 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
62 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
63 Runtime error 3 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
64 Runtime error 3 ms 456 KB Execution killed with signal 11 (could be triggered by violating memory limits)
65 Runtime error 3 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
66 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
67 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
68 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
69 Runtime error 3 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
70 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
71 Runtime error 3 ms 500 KB Execution killed with signal 11 (could be triggered by violating memory limits)
72 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
73 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
74 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
75 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
76 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
77 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
78 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
79 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
80 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
81 Runtime error 3 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
82 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
83 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
84 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
85 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
86 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
87 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
88 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
89 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
90 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
91 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
92 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
93 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
94 Runtime error 2 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
95 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
96 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
97 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
98 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
99 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
100 Runtime error 3 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)