답안 #55462

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55462 2018-07-07T15:20:10 Z BThero Bomb (IZhO17_bomb) C++17
58 / 100
373 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;
                    
short up[2505][2505];

short 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;
        short l = 10000, r = 10000;

        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 = 10000;
            }
        }
    }

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

        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 = 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] + 1);
         ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 20 ms 26512 KB Output is correct
4 Correct 19 ms 26520 KB Output is correct
5 Correct 2 ms 26520 KB Output is correct
6 Correct 3 ms 26520 KB Output is correct
7 Correct 3 ms 26520 KB Output is correct
8 Correct 2 ms 26520 KB Output is correct
9 Correct 3 ms 26520 KB Output is correct
10 Correct 2 ms 26520 KB Output is correct
11 Correct 3 ms 26520 KB Output is correct
12 Correct 2 ms 26520 KB Output is correct
13 Correct 2 ms 26520 KB Output is correct
14 Correct 3 ms 26520 KB Output is correct
15 Correct 3 ms 26520 KB Output is correct
16 Correct 2 ms 26520 KB Output is correct
17 Correct 3 ms 26520 KB Output is correct
18 Correct 3 ms 26520 KB Output is correct
19 Correct 4 ms 26520 KB Output is correct
20 Correct 4 ms 26520 KB Output is correct
21 Correct 3 ms 26520 KB Output is correct
22 Correct 4 ms 26520 KB Output is correct
23 Correct 3 ms 26520 KB Output is correct
24 Correct 4 ms 26520 KB Output is correct
25 Correct 4 ms 26520 KB Output is correct
26 Correct 4 ms 26520 KB Output is correct
27 Correct 8 ms 26520 KB Output is correct
28 Correct 4 ms 26520 KB Output is correct
29 Correct 10 ms 26520 KB Output is correct
30 Correct 7 ms 26520 KB Output is correct
31 Correct 7 ms 26520 KB Output is correct
32 Correct 7 ms 26520 KB Output is correct
33 Correct 9 ms 26520 KB Output is correct
34 Correct 5 ms 26520 KB Output is correct
35 Correct 8 ms 26520 KB Output is correct
36 Correct 11 ms 26520 KB Output is correct
37 Correct 2 ms 26520 KB Output is correct
38 Correct 361 ms 39156 KB Output is correct
39 Correct 2 ms 39156 KB Output is correct
40 Correct 37 ms 39156 KB Output is correct
41 Correct 2 ms 39156 KB Output is correct
42 Correct 3 ms 39156 KB Output is correct
43 Correct 287 ms 46048 KB Output is correct
44 Correct 9 ms 46048 KB Output is correct
45 Correct 258 ms 52128 KB Output is correct
46 Correct 210 ms 58340 KB Output is correct
47 Correct 255 ms 64620 KB Output is correct
48 Correct 209 ms 70564 KB Output is correct
49 Correct 356 ms 76680 KB Output is correct
50 Correct 242 ms 82712 KB Output is correct
51 Correct 236 ms 88900 KB Output is correct
52 Correct 277 ms 95016 KB Output is correct
53 Correct 286 ms 101124 KB Output is correct
54 Correct 219 ms 105572 KB Output is correct
55 Correct 186 ms 110560 KB Output is correct
56 Correct 341 ms 119460 KB Output is correct
57 Correct 183 ms 119692 KB Output is correct
58 Correct 184 ms 130312 KB Output is correct
59 Runtime error 175 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.239', 'max-rss': '28156', 'csw-forced': '51', 'cg-mem': '132096', 'time': '0.175', 'csw-voluntary': '21'} 131072
60 Runtime error 231 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.291', 'max-rss': '31820', 'csw-forced': '31', 'cg-mem': '132096', 'time': '0.231', 'csw-voluntary': '25'} 131072
61 Runtime error 345 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.402', 'max-rss': '32164', 'csw-forced': '38', 'cg-mem': '132096', 'time': '0.345', 'csw-voluntary': '20'} 131072
62 Runtime error 360 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.403', 'max-rss': '32168', 'csw-forced': '55', 'cg-mem': '132096', 'time': '0.360', 'csw-voluntary': '18'} 131072
63 Runtime error 373 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.413', 'max-rss': '32168', 'csw-forced': '11', 'cg-mem': '132096', 'time': '0.373', 'csw-voluntary': '3'} 131072
64 Runtime error 186 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.224', 'max-rss': '32168', 'csw-forced': '3', 'cg-mem': '132096', 'time': '0.186', 'csw-voluntary': '3'} 131072
65 Runtime error 228 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.288', 'max-rss': '32168', 'csw-forced': '16', 'cg-mem': '132096', 'time': '0.228', 'csw-voluntary': '3'} 131072
66 Runtime error 247 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.298', 'max-rss': '32168', 'csw-forced': '16', 'cg-mem': '132096', 'time': '0.247', 'csw-voluntary': '3'} 131072
67 Runtime error 220 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.257', 'max-rss': '32168', 'csw-forced': '8', 'cg-mem': '132096', 'time': '0.220', 'csw-voluntary': '3'} 131072
68 Runtime error 236 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.288', 'max-rss': '32172', 'csw-forced': '11', 'cg-mem': '132096', 'time': '0.236', 'csw-voluntary': '3'} 131072
69 Runtime error 155 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.211', 'max-rss': '25704', 'csw-forced': '32', 'cg-mem': '132096', 'time': '0.155', 'csw-voluntary': '3'} 131072
70 Runtime error 73 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.115', 'max-rss': '14444', 'csw-forced': '5', 'cg-mem': '132096', 'time': '0.073', 'csw-voluntary': '3'} 131072
71 Runtime error 136 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.174', 'max-rss': '24500', 'csw-forced': '4', 'cg-mem': '132096', 'time': '0.136', 'csw-voluntary': '3'} 131072
72 Runtime error 178 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.241', 'max-rss': '25860', 'csw-forced': '21', 'cg-mem': '132096', 'time': '0.178', 'csw-voluntary': '3'} 131072
73 Runtime error 155 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.200', 'max-rss': '25120', 'csw-forced': '7', 'cg-mem': '132096', 'time': '0.155', 'csw-voluntary': '2'} 131072
74 Runtime error 165 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.210', 'max-rss': '27488', 'csw-forced': '13', 'cg-mem': '132096', 'time': '0.165', 'csw-voluntary': '3'} 131072
75 Runtime error 163 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.213', 'max-rss': '28540', 'csw-forced': '15', 'cg-mem': '132096', 'time': '0.163', 'csw-voluntary': '8'} 131072
76 Runtime error 166 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.227', 'max-rss': '29284', 'csw-forced': '16', 'cg-mem': '132096', 'time': '0.166', 'csw-voluntary': '8'} 131072
77 Runtime error 153 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.196', 'max-rss': '29120', 'csw-forced': '3', 'cg-mem': '132096', 'time': '0.153', 'csw-voluntary': '3'} 131072
78 Runtime error 150 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.187', 'max-rss': '29688', 'csw-forced': '10', 'cg-mem': '132096', 'time': '0.150', 'csw-voluntary': '3'} 131072
79 Runtime error 93 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.135', 'max-rss': '12872', 'csw-forced': '5', 'cg-mem': '132096', 'time': '0.093', 'csw-voluntary': '3'} 131072
80 Runtime error 98 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.151', 'max-rss': '14192', 'csw-forced': '11', 'cg-mem': '132096', 'time': '0.098', 'csw-voluntary': '3'} 131072
81 Runtime error 110 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.157', 'max-rss': '13864', 'csw-forced': '21', 'cg-mem': '132096', 'time': '0.110', 'csw-voluntary': '3'} 131072
82 Runtime error 192 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.235', 'max-rss': '31240', 'csw-forced': '18', 'cg-mem': '132096', 'time': '0.192', 'csw-voluntary': '3'} 131072
83 Runtime error 202 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.254', 'max-rss': '31564', 'csw-forced': '21', 'cg-mem': '132096', 'time': '0.202', 'csw-voluntary': '3'} 131072
84 Runtime error 111 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.159', 'max-rss': '8228', 'csw-forced': '6', 'cg-mem': '132096', 'time': '0.111', 'csw-voluntary': '3'} 131072
85 Runtime error 164 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.216', 'max-rss': '32160', 'csw-forced': '9', 'cg-mem': '132096', 'time': '0.164', 'csw-voluntary': '3'} 131072
86 Runtime error 342 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.406', 'max-rss': '31988', 'csw-forced': '26', 'cg-mem': '132096', 'time': '0.342', 'csw-voluntary': '3'} 131072
87 Runtime error 188 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.250', 'max-rss': '32160', 'csw-forced': '11', 'cg-mem': '132096', 'time': '0.188', 'csw-voluntary': '3'} 131072
88 Runtime error 204 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.246', 'max-rss': '30212', 'csw-forced': '24', 'cg-mem': '132096', 'time': '0.204', 'csw-voluntary': '3'} 131072
89 Runtime error 186 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.227', 'max-rss': '31912', 'csw-forced': '22', 'cg-mem': '132096', 'time': '0.186', 'csw-voluntary': '3'} 131072
90 Runtime error 77 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.117', 'max-rss': '26048', 'csw-forced': '12', 'cg-mem': '132096', 'time': '0.077', 'csw-voluntary': '3'} 131072
91 Runtime error 169 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.211', 'max-rss': '32156', 'csw-forced': '6', 'cg-mem': '132096', 'time': '0.169', 'csw-voluntary': '3'} 131072
92 Runtime error 225 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.263', 'max-rss': '31644', 'csw-forced': '29', 'cg-mem': '132096', 'time': '0.225', 'csw-voluntary': '3'} 131072
93 Runtime error 296 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.363', 'max-rss': '31876', 'csw-forced': '79', 'cg-mem': '132096', 'time': '0.296', 'csw-voluntary': '3'} 131072
94 Runtime error 188 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.225', 'max-rss': '31728', 'csw-forced': '24', 'cg-mem': '132096', 'time': '0.188', 'csw-voluntary': '3'} 131072
95 Runtime error 151 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.202', 'max-rss': '31544', 'csw-forced': '8', 'cg-mem': '132096', 'time': '0.151', 'csw-voluntary': '3'} 131072
96 Runtime error 147 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.195', 'max-rss': '31212', 'csw-forced': '6', 'cg-mem': '132096', 'time': '0.147', 'csw-voluntary': '3'} 131072
97 Runtime error 320 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.380', 'max-rss': '31980', 'csw-forced': '23', 'cg-mem': '132096', 'time': '0.320', 'csw-voluntary': '3'} 131072
98 Runtime error 217 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.292', 'max-rss': '30984', 'csw-forced': '12', 'cg-mem': '132096', 'time': '0.217', 'csw-voluntary': '2'} 131072
99 Runtime error 229 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.278', 'max-rss': '31744', 'csw-forced': '8', 'cg-mem': '132096', 'time': '0.229', 'csw-voluntary': '3'} 131072
100 Runtime error 300 ms 132096 KB Memory limit exceeded 132096 {'time-wall': '0.349', 'max-rss': '31824', 'csw-forced': '31', 'cg-mem': '132096', 'time': '0.300', 'csw-voluntary': '3'} 131072