답안 #337907

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337907 2020-12-22T05:33:13 Z BY_KUTBILIM Bomb (IZhO17_bomb) C++14
78 / 100
555 ms 114412 KB
/** @BY_KUTBILIM **/
#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define all(x) ((x).begin(), (x).end())
#define rall(x) ((x).rbegin(), (x).end())

const int inf = (int)1e9+7;

int up[2505][2505], down[2505][2505];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie();

    int n, m;
    cin >> n >> m;
    bool a[n][m];
    char ch;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> ch;
            a[i][j] = bool(ch - '0');
        }
    }
    int W = m, H = n, len;
    for(int i = 0; i < n; i++){
        len = 0;
        for(int j = 0; j < m; j++){
            if(a[i][j])len++;
            else{
                if(len)W = min(W, len);
                len = 0;
            }
        }
        if(len)W = min(W, len);
    }
    for(int j = 0; j < m; j++){
        len = 0;
        for(int i = 0; i < n; i++){
            if(a[i][j])len++;
            else{
                if(len)H = min(H, len);
                len = 0;
            }
        }
        if(len)H = min(H, len);
    }
    
    for(int j = 0; j < m; j++){
        for(int i = 0; i < n; i++){
            if(a[i][j]){
                up[i][j] = (i ? up[i-1][j] : 0) + 1;
            }
        }
        for(int i = n - 1; i >= 0; i--){
            if(a[i][j]){
                down[i][j] = (i < n - 1 ? down[i+1][j] : 0) + 1;
            }
        }
    }
    
    vector<int> ans(2510, H);
    int l, r;
    for(int i = 0; i < n; i++){
        l = inf, r = inf, len = 0;
        for(int j = 0; j < m; j++){
            if(a[i][j]){
                r = min(r, up[i][j]);
                l = min(l, down[i][j]);
                ans[len] = min(ans[len], r + l - 1);
                len++;
            } else len = 0, l = inf, r = inf;
        }
        for(int j = m - 1; j >= 0; j--){
            if(a[i][j]){
                r = min(r, up[i][j]);
                l = min(l, down[i][j]);
                ans[len] = min(ans[len], r + l - 1);
                len++;
            } else len = 0, l = inf, r = inf;
        }
    }
    int res = ans[0];
    for(int i = 1; i < W; i++){
        ans[i] = min(ans[i], ans[i-1]);
        res = max(res, ans[i] * (i+1));
    }
    cout << res;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 10 ms 20460 KB Output is correct
4 Correct 12 ms 20332 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 876 KB Output is correct
18 Correct 1 ms 620 KB Output is correct
19 Correct 1 ms 788 KB Output is correct
20 Correct 1 ms 876 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 620 KB Output is correct
23 Correct 2 ms 876 KB Output is correct
24 Correct 1 ms 876 KB Output is correct
25 Correct 1 ms 1132 KB Output is correct
26 Correct 2 ms 1260 KB Output is correct
27 Correct 6 ms 3436 KB Output is correct
28 Correct 4 ms 1004 KB Output is correct
29 Correct 7 ms 4460 KB Output is correct
30 Correct 8 ms 3564 KB Output is correct
31 Correct 8 ms 2540 KB Output is correct
32 Correct 8 ms 3436 KB Output is correct
33 Correct 11 ms 4588 KB Output is correct
34 Correct 3 ms 1004 KB Output is correct
35 Correct 7 ms 1260 KB Output is correct
36 Correct 11 ms 5996 KB Output is correct
37 Correct 1 ms 492 KB Output is correct
38 Runtime error 538 ms 114412 KB Execution killed with signal 6 (could be triggered by violating memory limits)
39 Correct 1 ms 492 KB Output is correct
40 Correct 52 ms 14956 KB Output is correct
41 Correct 1 ms 492 KB Output is correct
42 Correct 1 ms 1260 KB Output is correct
43 Correct 411 ms 53484 KB Output is correct
44 Correct 10 ms 5356 KB Output is correct
45 Runtime error 476 ms 108012 KB Execution killed with signal 6 (could be triggered by violating memory limits)
46 Correct 402 ms 55692 KB Output is correct
47 Runtime error 484 ms 107116 KB Execution killed with signal 6 (could be triggered by violating memory limits)
48 Runtime error 470 ms 112492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
49 Runtime error 555 ms 112312 KB Execution killed with signal 6 (could be triggered by violating memory limits)
50 Runtime error 461 ms 112240 KB Execution killed with signal 6 (could be triggered by violating memory limits)
51 Runtime error 458 ms 112244 KB Execution killed with signal 6 (could be triggered by violating memory limits)
52 Runtime error 494 ms 112264 KB Execution killed with signal 6 (could be triggered by violating memory limits)
53 Runtime error 469 ms 110928 KB Execution killed with signal 6 (could be triggered by violating memory limits)
54 Correct 342 ms 42272 KB Output is correct
55 Correct 341 ms 40428 KB Output is correct
56 Correct 483 ms 55532 KB Output is correct
57 Correct 322 ms 35656 KB Output is correct
58 Runtime error 426 ms 82156 KB Execution killed with signal 6 (could be triggered by violating memory limits)
59 Correct 315 ms 37356 KB Output is correct
60 Runtime error 449 ms 95724 KB Execution killed with signal 6 (could be triggered by violating memory limits)
61 Correct 475 ms 55532 KB Output is correct
62 Correct 468 ms 55492 KB Output is correct
63 Correct 484 ms 55680 KB Output is correct
64 Runtime error 443 ms 77548 KB Execution killed with signal 6 (could be triggered by violating memory limits)
65 Runtime error 454 ms 110060 KB Execution killed with signal 6 (could be triggered by violating memory limits)
66 Runtime error 457 ms 103788 KB Execution killed with signal 6 (could be triggered by violating memory limits)
67 Runtime error 487 ms 112236 KB Execution killed with signal 6 (could be triggered by violating memory limits)
68 Runtime error 482 ms 112344 KB Execution killed with signal 6 (could be triggered by violating memory limits)
69 Correct 317 ms 35100 KB Output is correct
70 Correct 146 ms 14188 KB Output is correct
71 Correct 336 ms 28112 KB Output is correct
72 Correct 308 ms 33644 KB Output is correct
73 Correct 317 ms 34156 KB Output is correct
74 Correct 338 ms 35748 KB Output is correct
75 Correct 330 ms 37228 KB Output is correct
76 Correct 341 ms 38636 KB Output is correct
77 Correct 319 ms 39084 KB Output is correct
78 Correct 340 ms 39276 KB Output is correct
79 Correct 240 ms 11756 KB Output is correct
80 Correct 253 ms 13036 KB Output is correct
81 Correct 255 ms 13420 KB Output is correct
82 Correct 330 ms 41836 KB Output is correct
83 Correct 324 ms 41964 KB Output is correct
84 Correct 248 ms 7108 KB Output is correct
85 Correct 333 ms 40812 KB Output is correct
86 Runtime error 533 ms 109932 KB Execution killed with signal 6 (could be triggered by violating memory limits)
87 Correct 329 ms 39748 KB Output is correct
88 Correct 336 ms 40708 KB Output is correct
89 Correct 360 ms 49388 KB Output is correct
90 Correct 213 ms 28536 KB Output is correct
91 Runtime error 429 ms 90220 KB Execution killed with signal 6 (could be triggered by violating memory limits)
92 Runtime error 454 ms 93548 KB Execution killed with signal 6 (could be triggered by violating memory limits)
93 Runtime error 520 ms 108396 KB Execution killed with signal 6 (could be triggered by violating memory limits)
94 Runtime error 452 ms 97392 KB Execution killed with signal 6 (could be triggered by violating memory limits)
95 Correct 329 ms 41956 KB Output is correct
96 Correct 328 ms 41656 KB Output is correct
97 Correct 444 ms 54508 KB Output is correct
98 Correct 322 ms 41452 KB Output is correct
99 Correct 359 ms 47724 KB Output is correct
100 Runtime error 503 ms 107244 KB Execution killed with signal 6 (could be triggered by violating memory limits)