답안 #55459

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55459 2018-07-07T15:16:41 Z BThero Bomb (IZhO17_bomb) C++17
55 / 100
397 ms 132096 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;
                    
int up[2505][2505];

int dw[2505][2505];

char s[2505][2505];

int f[2505];

int n, m, ans;

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

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

    int limh = n, limw = m;

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

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

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

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

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

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

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

        for (int i = n; 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 = 1; i <= n; ++i) {
        int cur = 0, l = 100000, r = 100000;

        for (int j = 1; 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 = 100000;
            }
        }
    }

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

        for (int j = m; 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 = 100000;
            }
        }
    }

    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] + 1);
         ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 584 KB Output is correct
3 Correct 21 ms 26704 KB Output is correct
4 Correct 21 ms 26788 KB Output is correct
5 Correct 2 ms 26788 KB Output is correct
6 Correct 4 ms 26788 KB Output is correct
7 Correct 2 ms 26788 KB Output is correct
8 Correct 3 ms 26788 KB Output is correct
9 Correct 3 ms 26788 KB Output is correct
10 Correct 2 ms 26788 KB Output is correct
11 Correct 3 ms 26788 KB Output is correct
12 Correct 3 ms 26788 KB Output is correct
13 Correct 3 ms 26788 KB Output is correct
14 Correct 2 ms 26788 KB Output is correct
15 Correct 2 ms 26788 KB Output is correct
16 Correct 3 ms 26788 KB Output is correct
17 Correct 3 ms 26788 KB Output is correct
18 Correct 4 ms 26788 KB Output is correct
19 Correct 3 ms 26788 KB Output is correct
20 Correct 3 ms 26788 KB Output is correct
21 Correct 3 ms 26788 KB Output is correct
22 Correct 2 ms 26788 KB Output is correct
23 Correct 3 ms 26788 KB Output is correct
24 Correct 4 ms 26788 KB Output is correct
25 Correct 4 ms 26788 KB Output is correct
26 Correct 3 ms 26788 KB Output is correct
27 Correct 6 ms 26788 KB Output is correct
28 Correct 5 ms 26788 KB Output is correct
29 Correct 8 ms 26788 KB Output is correct
30 Correct 7 ms 26788 KB Output is correct
31 Correct 6 ms 26788 KB Output is correct
32 Correct 8 ms 26788 KB Output is correct
33 Correct 9 ms 26788 KB Output is correct
34 Correct 4 ms 26788 KB Output is correct
35 Correct 7 ms 26788 KB Output is correct
36 Correct 12 ms 26788 KB Output is correct
37 Correct 2 ms 26788 KB Output is correct
38 Correct 373 ms 63580 KB Output is correct
39 Correct 2 ms 63580 KB Output is correct
40 Correct 33 ms 63580 KB Output is correct
41 Correct 2 ms 63580 KB Output is correct
42 Correct 3 ms 63580 KB Output is correct
43 Correct 297 ms 66560 KB Output is correct
44 Correct 9 ms 66560 KB Output is correct
45 Correct 267 ms 74352 KB Output is correct
46 Correct 241 ms 82764 KB Output is correct
47 Correct 272 ms 86504 KB Output is correct
48 Correct 245 ms 95144 KB Output is correct
49 Correct 366 ms 101360 KB Output is correct
50 Correct 256 ms 107336 KB Output is correct
51 Correct 250 ms 113456 KB Output is correct
52 Correct 264 ms 119568 KB Output is correct
53 Correct 261 ms 124912 KB Output is correct
54 Correct 186 ms 124912 KB Output is correct
55 Correct 173 ms 124912 KB Output is correct
56 Runtime error 385 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.436', 'max-rss': '56624', 'csw-forced': '61', 'cg-mem': '132096', 'time': '0.385', 'csw-voluntary': '10'} 131072
57 Runtime error 168 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.228', 'max-rss': '36700', 'csw-forced': '55', 'cg-mem': '132096', 'time': '0.168', 'csw-voluntary': '7'} 131072
58 Runtime error 183 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.266', 'max-rss': '41640', 'csw-forced': '41', 'cg-mem': '132096', 'time': '0.183', 'csw-voluntary': '16'} 131072
59 Runtime error 175 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.228', 'max-rss': '38588', 'csw-forced': '49', 'cg-mem': '132096', 'time': '0.175', 'csw-voluntary': '10'} 131072
60 Runtime error 254 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.307', 'max-rss': '48444', 'csw-forced': '66', 'cg-mem': '132096', 'time': '0.254', 'csw-voluntary': '9'} 131072
61 Runtime error 397 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.447', 'max-rss': '56636', 'csw-forced': '72', 'cg-mem': '132096', 'time': '0.397', 'csw-voluntary': '8'} 131072
62 Runtime error 380 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.423', 'max-rss': '56624', 'csw-forced': '60', 'cg-mem': '132096', 'time': '0.380', 'csw-voluntary': '8'} 131072
63 Runtime error 366 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.421', 'max-rss': '56628', 'csw-forced': '76', 'cg-mem': '132096', 'time': '0.366', 'csw-voluntary': '10'} 131072
64 Runtime error 160 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.210', 'max-rss': '39468', 'csw-forced': '56', 'cg-mem': '132096', 'time': '0.160', 'csw-voluntary': '8'} 131072
65 Runtime error 284 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.323', 'max-rss': '55568', 'csw-forced': '63', 'cg-mem': '132096', 'time': '0.284', 'csw-voluntary': '5'} 131072
66 Runtime error 232 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.283', 'max-rss': '52484', 'csw-forced': '50', 'cg-mem': '132096', 'time': '0.232', 'csw-voluntary': '11'} 131072
67 Runtime error 284 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.349', 'max-rss': '56632', 'csw-forced': '54', 'cg-mem': '132096', 'time': '0.284', 'csw-voluntary': '10'} 131072
68 Runtime error 289 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.332', 'max-rss': '56632', 'csw-forced': '63', 'cg-mem': '132096', 'time': '0.289', 'csw-voluntary': '11'} 131072
69 Runtime error 170 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.229', 'max-rss': '36256', 'csw-forced': '58', 'cg-mem': '132096', 'time': '0.170', 'csw-voluntary': '8'} 131072
70 Runtime error 59 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.102', 'max-rss': '16404', 'csw-forced': '36', 'cg-mem': '132096', 'time': '0.059', 'csw-voluntary': '8'} 131072
71 Runtime error 131 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.168', 'max-rss': '29252', 'csw-forced': '63', 'cg-mem': '132096', 'time': '0.131', 'csw-voluntary': '6'} 131072
72 Runtime error 178 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.228', 'max-rss': '34760', 'csw-forced': '67', 'cg-mem': '132096', 'time': '0.178', 'csw-voluntary': '6'} 131072
73 Runtime error 175 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.223', 'max-rss': '35216', 'csw-forced': '64', 'cg-mem': '132096', 'time': '0.175', 'csw-voluntary': '11'} 131072
74 Runtime error 171 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.232', 'max-rss': '36756', 'csw-forced': '59', 'cg-mem': '132096', 'time': '0.171', 'csw-voluntary': '10'} 131072
75 Runtime error 173 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.214', 'max-rss': '38356', 'csw-forced': '55', 'cg-mem': '132096', 'time': '0.173', 'csw-voluntary': '9'} 131072
76 Runtime error 212 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.275', 'max-rss': '39692', 'csw-forced': '11', 'cg-mem': '132096', 'time': '0.212', 'csw-voluntary': '3'} 131072
77 Runtime error 194 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.248', 'max-rss': '40188', 'csw-forced': '15', 'cg-mem': '132096', 'time': '0.194', 'csw-voluntary': '3'} 131072
78 Runtime error 171 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.209', 'max-rss': '40416', 'csw-forced': '11', 'cg-mem': '132096', 'time': '0.171', 'csw-voluntary': '3'} 131072
79 Runtime error 97 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.145', 'max-rss': '12944', 'csw-forced': '18', 'cg-mem': '132096', 'time': '0.097', 'csw-voluntary': '3'} 131072
80 Runtime error 94 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.140', 'max-rss': '14244', 'csw-forced': '5', 'cg-mem': '132096', 'time': '0.094', 'csw-voluntary': '3'} 131072
81 Runtime error 99 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.151', 'max-rss': '14624', 'csw-forced': '16', 'cg-mem': '132096', 'time': '0.099', 'csw-voluntary': '3'} 131072
82 Runtime error 188 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.239', 'max-rss': '42920', 'csw-forced': '13', 'cg-mem': '132096', 'time': '0.188', 'csw-voluntary': '3'} 131072
83 Runtime error 182 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.229', 'max-rss': '43100', 'csw-forced': '13', 'cg-mem': '132096', 'time': '0.182', 'csw-voluntary': '3'} 131072
84 Runtime error 91 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.127', 'max-rss': '8280', 'csw-forced': '26', 'cg-mem': '132096', 'time': '0.091', 'csw-voluntary': '3'} 131072
85 Runtime error 153 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.209', 'max-rss': '42016', 'csw-forced': '4', 'cg-mem': '132096', 'time': '0.153', 'csw-voluntary': '3'} 131072
86 Runtime error 355 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.399', 'max-rss': '55520', 'csw-forced': '18', 'cg-mem': '132096', 'time': '0.355', 'csw-voluntary': '3'} 131072
87 Runtime error 150 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.188', 'max-rss': '40916', 'csw-forced': '24', 'cg-mem': '132096', 'time': '0.150', 'csw-voluntary': '3'} 131072
88 Runtime error 158 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.196', 'max-rss': '41816', 'csw-forced': '15', 'cg-mem': '132096', 'time': '0.158', 'csw-voluntary': '3'} 131072
89 Runtime error 239 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.286', 'max-rss': '50580', 'csw-forced': '36', 'cg-mem': '132096', 'time': '0.239', 'csw-voluntary': '3'} 131072
90 Runtime error 102 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.139', 'max-rss': '30644', 'csw-forced': '21', 'cg-mem': '132096', 'time': '0.102', 'csw-voluntary': '3'} 131072
91 Runtime error 178 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.228', 'max-rss': '45748', 'csw-forced': '19', 'cg-mem': '132096', 'time': '0.178', 'csw-voluntary': '3'} 131072
92 Runtime error 218 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.274', 'max-rss': '47408', 'csw-forced': '12', 'cg-mem': '132096', 'time': '0.218', 'csw-voluntary': '3'} 131072
93 Runtime error 368 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.429', 'max-rss': '54620', 'csw-forced': '9', 'cg-mem': '132096', 'time': '0.368', 'csw-voluntary': '3'} 131072
94 Runtime error 245 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.321', 'max-rss': '49240', 'csw-forced': '23', 'cg-mem': '132096', 'time': '0.245', 'csw-voluntary': '3'} 131072
95 Runtime error 188 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.223', 'max-rss': '43148', 'csw-forced': '4', 'cg-mem': '132096', 'time': '0.188', 'csw-voluntary': '3'} 131072
96 Runtime error 216 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.258', 'max-rss': '42796', 'csw-forced': '16', 'cg-mem': '132096', 'time': '0.216', 'csw-voluntary': '3'} 131072
97 Runtime error 337 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.384', 'max-rss': '55376', 'csw-forced': '17', 'cg-mem': '132096', 'time': '0.337', 'csw-voluntary': '3'} 131072
98 Runtime error 208 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.277', 'max-rss': '42632', 'csw-forced': '38', 'cg-mem': '132096', 'time': '0.208', 'csw-voluntary': '3'} 131072
99 Runtime error 218 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.260', 'max-rss': '48868', 'csw-forced': '9', 'cg-mem': '132096', 'time': '0.218', 'csw-voluntary': '3'} 131072
100 Runtime error 338 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.388', 'max-rss': '54152', 'csw-forced': '9', 'cg-mem': '132096', 'time': '0.338', 'csw-voluntary': '3'} 131072