Submission #55483

# Submission time Handle Problem Language Result Execution time Memory
55483 2018-07-07T16:50:22 Z BThero Bomb (IZhO17_bomb) C++14
100 / 100
360 ms 69920 KB
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;
                    
short up[2502][2502];

short dw[2502][2502];

char s[2502][2502];

int f[2502];

int n, m, ans;

void solve() {
    scanf("%d %d", &n, &m);

    for (int i = 0; i < n; ++i) {
        scanf("%s", s[i]);
    }

    int limh = n, limw = m;

    for (int i = 0; i < n; ++i) {
        int cur = 0;

        for (int j = 0; j < m; ++j) {
            if (s[i][j] == '1') {
                ++cur;

                if (j + 1 == m || s[i][j + 1] == '0') {
                    limw = min(limw, cur);
                }
            }   
            else {
                cur = 0;
            }
        }    
    }

    for (int j = 0; j < m; ++j) {
        int cur = 0;

        for (int i = 0; i < n; ++i) {
            if (s[i][j] == '1') {
                up[i][j] = ++cur;

                if (i + 1 == n || s[i + 1][j] == '0') {
                    limh = min(limh, cur);
                }
            }
            else {
                cur = 0;
            }
        }
    }

    for (int j = 0; j < m; ++j) {
        int cur = 0;

        for (int i = n - 1; i >= 0; --i) {
            if (s[i][j] == '1') {
                dw[i][j] = ++cur;
            }
            else {
                cur = 0;
            }
        }
    }

    for (int i = 1; i <= limw; ++i) {
        f[i] = limh;
    }

    for (int i = 0; i < n; ++i) {
        int cur = 0;
        short l = 10000, r = 10000;

        for (int j = 0; j < m; ++j) {
            if (s[i][j] == '1') {
                ++cur;

                l = min(l, up[i][j]);
                r = min(r, dw[i][j]);

                f[cur] = min(f[cur], l + r - 1);
            }
            else {
                cur = 0;
                l = r = 10000;
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        int cur = 0;
        short l = 10000, r = 10000;

        for (int j = m - 1; j >= 0; --j) {
            if (s[i][j] == '1') {
                ++cur;

                l = min(l, up[i][j]);
                r = min(r, dw[i][j]);

                f[cur] = min(f[cur], l + r - 1);
            }
            else {
                cur = 0;
                l = r = 10000;
            }
        }
    }

    ans = f[1];                    

    for (int i = 2; i <= limw; ++i) {
        f[i] = min(f[i], f[i - 1]);
        ans = max(ans, i * f[i]);
    }

    printf("%d\n", ans);
}

int main() {
    //freopen("bomb.in", "r", stdin);
    //freopen("bomb.out", "w", stdout);
          
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Compilation message

bomb.cpp: In function 'void solve()':
bomb.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
bomb.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", s[i]);
         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 25 ms 26552 KB Output is correct
4 Correct 23 ms 26596 KB Output is correct
5 Correct 3 ms 26596 KB Output is correct
6 Correct 3 ms 26596 KB Output is correct
7 Correct 4 ms 26596 KB Output is correct
8 Correct 2 ms 26596 KB Output is correct
9 Correct 3 ms 26596 KB Output is correct
10 Correct 3 ms 26596 KB Output is correct
11 Correct 3 ms 26596 KB Output is correct
12 Correct 7 ms 26596 KB Output is correct
13 Correct 3 ms 26596 KB Output is correct
14 Correct 3 ms 26596 KB Output is correct
15 Correct 3 ms 26596 KB Output is correct
16 Correct 2 ms 26596 KB Output is correct
17 Correct 4 ms 26596 KB Output is correct
18 Correct 3 ms 26596 KB Output is correct
19 Correct 4 ms 26596 KB Output is correct
20 Correct 3 ms 26596 KB Output is correct
21 Correct 3 ms 26596 KB Output is correct
22 Correct 3 ms 26596 KB Output is correct
23 Correct 3 ms 26596 KB Output is correct
24 Correct 3 ms 26596 KB Output is correct
25 Correct 2 ms 26596 KB Output is correct
26 Correct 3 ms 26596 KB Output is correct
27 Correct 6 ms 26596 KB Output is correct
28 Correct 4 ms 26596 KB Output is correct
29 Correct 7 ms 26596 KB Output is correct
30 Correct 7 ms 26596 KB Output is correct
31 Correct 7 ms 26596 KB Output is correct
32 Correct 7 ms 26596 KB Output is correct
33 Correct 8 ms 26596 KB Output is correct
34 Correct 5 ms 26596 KB Output is correct
35 Correct 7 ms 26596 KB Output is correct
36 Correct 11 ms 26596 KB Output is correct
37 Correct 3 ms 26596 KB Output is correct
38 Correct 323 ms 38960 KB Output is correct
39 Correct 3 ms 38960 KB Output is correct
40 Correct 25 ms 38960 KB Output is correct
41 Correct 2 ms 38960 KB Output is correct
42 Correct 3 ms 38960 KB Output is correct
43 Correct 299 ms 46044 KB Output is correct
44 Correct 14 ms 46044 KB Output is correct
45 Correct 270 ms 52228 KB Output is correct
46 Correct 211 ms 58260 KB Output is correct
47 Correct 247 ms 64420 KB Output is correct
48 Correct 207 ms 64804 KB Output is correct
49 Correct 327 ms 64804 KB Output is correct
50 Correct 272 ms 64824 KB Output is correct
51 Correct 254 ms 64952 KB Output is correct
52 Correct 282 ms 64952 KB Output is correct
53 Correct 217 ms 64952 KB Output is correct
54 Correct 154 ms 64952 KB Output is correct
55 Correct 161 ms 64952 KB Output is correct
56 Correct 342 ms 64952 KB Output is correct
57 Correct 193 ms 64952 KB Output is correct
58 Correct 157 ms 64952 KB Output is correct
59 Correct 161 ms 64952 KB Output is correct
60 Correct 248 ms 64952 KB Output is correct
61 Correct 320 ms 64952 KB Output is correct
62 Correct 360 ms 64952 KB Output is correct
63 Correct 324 ms 64960 KB Output is correct
64 Correct 184 ms 64960 KB Output is correct
65 Correct 235 ms 64960 KB Output is correct
66 Correct 264 ms 64960 KB Output is correct
67 Correct 227 ms 64960 KB Output is correct
68 Correct 239 ms 64960 KB Output is correct
69 Correct 173 ms 64960 KB Output is correct
70 Correct 84 ms 64960 KB Output is correct
71 Correct 151 ms 64960 KB Output is correct
72 Correct 131 ms 64960 KB Output is correct
73 Correct 141 ms 64960 KB Output is correct
74 Correct 139 ms 64960 KB Output is correct
75 Correct 184 ms 64960 KB Output is correct
76 Correct 147 ms 66360 KB Output is correct
77 Correct 151 ms 66616 KB Output is correct
78 Correct 222 ms 67104 KB Output is correct
79 Correct 112 ms 67104 KB Output is correct
80 Correct 84 ms 67104 KB Output is correct
81 Correct 90 ms 67104 KB Output is correct
82 Correct 154 ms 68764 KB Output is correct
83 Correct 151 ms 69152 KB Output is correct
84 Correct 100 ms 69152 KB Output is correct
85 Correct 153 ms 69648 KB Output is correct
86 Correct 335 ms 69648 KB Output is correct
87 Correct 167 ms 69664 KB Output is correct
88 Correct 188 ms 69664 KB Output is correct
89 Correct 227 ms 69664 KB Output is correct
90 Correct 97 ms 69664 KB Output is correct
91 Correct 210 ms 69920 KB Output is correct
92 Correct 258 ms 69920 KB Output is correct
93 Correct 316 ms 69920 KB Output is correct
94 Correct 220 ms 69920 KB Output is correct
95 Correct 197 ms 69920 KB Output is correct
96 Correct 228 ms 69920 KB Output is correct
97 Correct 351 ms 69920 KB Output is correct
98 Correct 193 ms 69920 KB Output is correct
99 Correct 217 ms 69920 KB Output is correct
100 Correct 348 ms 69920 KB Output is correct