답안 #706320

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706320 2023-03-06T09:26:32 Z KiriLL1ca Bomb (IZhO17_bomb) C++17
32 / 100
257 ms 57228 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fr first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define endl '\n'
#define sz(x) (int)((x).size())
#define vec vector
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;

template <typename T> inline bool umin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool umax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int inf = 1e9 + 17;

inline void solve () {
    int n, m; cin >> n >> m;
    vec <string> a (n);
    for (auto &i : a) cin >> i;

    vec <int> mx (m + 1, inf);

    vec <vec <int>> p (n, vec <int> (m)), s (n, vec <int> (m));
    for (int j = 0; j < n; ++j) {
        p[0][j] = (a[0][j] == '1');
        for (int i = 1; i < n; ++i) {
            if (a[i][j] == '1') p[i][j] = p[i - 1][j] + 1;
        }

        s[n - 1][j] = (a[n - 1][j] == '1');
        for (int i = n - 2; ~i; --i) {
            if (a[i][j] == '1') s[i][j] = s[i + 1][j] + 1;
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int l = 0, r = 0; r < m; ) {
            while (r < m && a[i][r] == '1') ++r;
            if (l == r) {
                ++l, ++r;
                continue;
            }

            int mn_down = inf, mn_up = inf;
            for (int q = l; q < r; ++q) {
                umin(mn_up, p[i][q]);
                umin(mn_down, s[i][q]);
                umin(mx[q - l + 1], mn_down + mn_up - 1);
            }
            umin(mx[r - l + 1], 0);

            l = r;
        }
    }

    int ans = 0;
    for (int i = 1; i <= m; ++i) {
        umin(mx[i], mx[i - 1]);
        umax(ans, mx[i] * i);
    }
    cout << ans << endl;
}

signed main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif// LOCAL
    int t = 1; //cin >> t;
    while (t--) solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Runtime error 1 ms 468 KB Execution killed with signal 6
3 Runtime error 3 ms 1108 KB Execution killed with signal 11
4 Runtime error 2 ms 1108 KB Execution killed with signal 11
5 Incorrect 1 ms 340 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Runtime error 1 ms 468 KB Execution killed with signal 6
8 Incorrect 1 ms 212 KB Output isn't correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Incorrect 1 ms 212 KB Output isn't correct
13 Runtime error 1 ms 560 KB Execution killed with signal 6
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 1 ms 212 KB Output isn't correct
16 Correct 1 ms 316 KB Output is correct
17 Incorrect 1 ms 340 KB Output isn't correct
18 Runtime error 1 ms 596 KB Execution killed with signal 6
19 Runtime error 1 ms 596 KB Execution killed with signal 6
20 Runtime error 1 ms 576 KB Execution killed with signal 6
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 324 KB Output is correct
23 Incorrect 1 ms 340 KB Output isn't correct
24 Runtime error 1 ms 596 KB Execution killed with signal 6
25 Incorrect 1 ms 340 KB Output isn't correct
26 Incorrect 1 ms 324 KB Output isn't correct
27 Runtime error 2 ms 1992 KB Execution killed with signal 6
28 Incorrect 2 ms 1352 KB Output isn't correct
29 Runtime error 4 ms 2888 KB Execution killed with signal 6
30 Incorrect 3 ms 2132 KB Output isn't correct
31 Correct 3 ms 1728 KB Output is correct
32 Runtime error 5 ms 3544 KB Execution killed with signal 6
33 Incorrect 3 ms 2260 KB Output isn't correct
34 Runtime error 4 ms 2100 KB Execution killed with signal 6
35 Incorrect 3 ms 2252 KB Output isn't correct
36 Incorrect 3 ms 2260 KB Output isn't correct
37 Incorrect 1 ms 212 KB Output isn't correct
38 Correct 232 ms 57184 KB Output is correct
39 Incorrect 1 ms 212 KB Output isn't correct
40 Incorrect 19 ms 8004 KB Output isn't correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 203 ms 57136 KB Output is correct
44 Correct 3 ms 2248 KB Output is correct
45 Incorrect 186 ms 57184 KB Output isn't correct
46 Correct 187 ms 57184 KB Output is correct
47 Incorrect 187 ms 57216 KB Output isn't correct
48 Correct 178 ms 57188 KB Output is correct
49 Incorrect 222 ms 57084 KB Output isn't correct
50 Correct 181 ms 57096 KB Output is correct
51 Correct 172 ms 57188 KB Output is correct
52 Correct 177 ms 57188 KB Output is correct
53 Correct 163 ms 57104 KB Output is correct
54 Correct 129 ms 57184 KB Output is correct
55 Incorrect 147 ms 57192 KB Output isn't correct
56 Correct 246 ms 57120 KB Output is correct
57 Incorrect 135 ms 57196 KB Output isn't correct
58 Correct 133 ms 57068 KB Output is correct
59 Correct 124 ms 57120 KB Output is correct
60 Incorrect 166 ms 57228 KB Output isn't correct
61 Incorrect 227 ms 57184 KB Output isn't correct
62 Incorrect 214 ms 57188 KB Output isn't correct
63 Incorrect 257 ms 57192 KB Output isn't correct
64 Incorrect 126 ms 57056 KB Output isn't correct
65 Correct 167 ms 56904 KB Output is correct
66 Correct 159 ms 56964 KB Output is correct
67 Correct 179 ms 56916 KB Output is correct
68 Correct 187 ms 56876 KB Output is correct
69 Correct 126 ms 56908 KB Output is correct
70 Incorrect 52 ms 36804 KB Output isn't correct
71 Incorrect 113 ms 56848 KB Output isn't correct
72 Incorrect 127 ms 56888 KB Output isn't correct
73 Correct 134 ms 56888 KB Output is correct
74 Incorrect 129 ms 56976 KB Output isn't correct
75 Incorrect 128 ms 56868 KB Output isn't correct
76 Incorrect 132 ms 56908 KB Output isn't correct
77 Incorrect 133 ms 56916 KB Output isn't correct
78 Incorrect 140 ms 56908 KB Output isn't correct
79 Incorrect 83 ms 56844 KB Output isn't correct
80 Incorrect 85 ms 56828 KB Output isn't correct
81 Incorrect 89 ms 56696 KB Output isn't correct
82 Incorrect 133 ms 56820 KB Output isn't correct
83 Incorrect 136 ms 56780 KB Output isn't correct
84 Incorrect 90 ms 56616 KB Output isn't correct
85 Incorrect 127 ms 56676 KB Output isn't correct
86 Incorrect 208 ms 56608 KB Output isn't correct
87 Incorrect 127 ms 56672 KB Output isn't correct
88 Correct 132 ms 56672 KB Output is correct
89 Correct 154 ms 56524 KB Output is correct
90 Incorrect 72 ms 36448 KB Output isn't correct
91 Incorrect 144 ms 56504 KB Output isn't correct
92 Incorrect 153 ms 56528 KB Output isn't correct
93 Incorrect 213 ms 56536 KB Output isn't correct
94 Correct 154 ms 56524 KB Output is correct
95 Incorrect 133 ms 56496 KB Output isn't correct
96 Correct 131 ms 56420 KB Output is correct
97 Incorrect 200 ms 56320 KB Output isn't correct
98 Incorrect 137 ms 56424 KB Output isn't correct
99 Incorrect 147 ms 56416 KB Output isn't correct
100 Incorrect 203 ms 56528 KB Output isn't correct