Submission #706323

# Submission time Handle Problem Language Result Execution time Memory
706323 2023-03-06T09:28:10 Z KiriLL1ca Bomb (IZhO17_bomb) C++17
32 / 100
201 ms 56280 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 + 2, 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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Runtime error 1 ms 468 KB Execution killed with signal 6
3 Runtime error 1 ms 1108 KB Execution killed with signal 11
4 Runtime error 2 ms 1108 KB Execution killed with signal 11
5 Incorrect 0 ms 340 KB Output isn't correct
6 Incorrect 0 ms 212 KB Output isn't correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Incorrect 1 ms 212 KB Output isn't correct
13 Runtime error 1 ms 468 KB Execution killed with signal 6
14 Correct 0 ms 212 KB Output is correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Correct 0 ms 212 KB Output is correct
17 Incorrect 0 ms 340 KB Output isn't correct
18 Runtime error 1 ms 468 KB Execution killed with signal 6
19 Runtime error 1 ms 596 KB Execution killed with signal 6
20 Runtime error 1 ms 596 KB Execution killed with signal 6
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 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 340 KB Output isn't correct
27 Runtime error 2 ms 1876 KB Execution killed with signal 6
28 Incorrect 1 ms 1236 KB Output isn't correct
29 Runtime error 3 ms 2772 KB Execution killed with signal 6
30 Incorrect 2 ms 2004 KB Output isn't correct
31 Correct 2 ms 1608 KB Output is correct
32 Runtime error 3 ms 3284 KB Execution killed with signal 6
33 Incorrect 2 ms 2132 KB Output isn't correct
34 Runtime error 2 ms 2004 KB Execution killed with signal 6
35 Incorrect 2 ms 2132 KB Output isn't correct
36 Incorrect 3 ms 2132 KB Output isn't correct
37 Incorrect 0 ms 212 KB Output isn't correct
38 Correct 174 ms 56160 KB Output is correct
39 Incorrect 0 ms 212 KB Output isn't correct
40 Incorrect 15 ms 7252 KB Output isn't correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 193 ms 56156 KB Output is correct
44 Correct 3 ms 2132 KB Output is correct
45 Incorrect 150 ms 56164 KB Output isn't correct
46 Correct 142 ms 56180 KB Output is correct
47 Incorrect 158 ms 56156 KB Output isn't correct
48 Correct 136 ms 56164 KB Output is correct
49 Incorrect 192 ms 56164 KB Output isn't correct
50 Correct 144 ms 56164 KB Output is correct
51 Correct 142 ms 56172 KB Output is correct
52 Correct 145 ms 56172 KB Output is correct
53 Correct 131 ms 56184 KB Output is correct
54 Correct 116 ms 56140 KB Output is correct
55 Incorrect 120 ms 56168 KB Output isn't correct
56 Correct 196 ms 56148 KB Output is correct
57 Incorrect 106 ms 56148 KB Output isn't correct
58 Correct 106 ms 56148 KB Output is correct
59 Correct 119 ms 56148 KB Output is correct
60 Incorrect 144 ms 56164 KB Output isn't correct
61 Incorrect 201 ms 56160 KB Output isn't correct
62 Incorrect 188 ms 56164 KB Output isn't correct
63 Incorrect 189 ms 56164 KB Output isn't correct
64 Incorrect 106 ms 56068 KB Output isn't correct
65 Correct 140 ms 56148 KB Output is correct
66 Correct 148 ms 56160 KB Output is correct
67 Correct 154 ms 56264 KB Output is correct
68 Correct 159 ms 56168 KB Output is correct
69 Correct 105 ms 56164 KB Output is correct
70 Incorrect 44 ms 36044 KB Output isn't correct
71 Incorrect 90 ms 56272 KB Output isn't correct
72 Incorrect 106 ms 56168 KB Output isn't correct
73 Correct 118 ms 56160 KB Output is correct
74 Incorrect 138 ms 56148 KB Output isn't correct
75 Incorrect 111 ms 56148 KB Output isn't correct
76 Incorrect 119 ms 56160 KB Output isn't correct
77 Incorrect 108 ms 56092 KB Output isn't correct
78 Incorrect 118 ms 56112 KB Output isn't correct
79 Incorrect 69 ms 56068 KB Output isn't correct
80 Incorrect 71 ms 56160 KB Output isn't correct
81 Incorrect 70 ms 56056 KB Output isn't correct
82 Incorrect 114 ms 56268 KB Output isn't correct
83 Incorrect 114 ms 56160 KB Output isn't correct
84 Incorrect 65 ms 56164 KB Output isn't correct
85 Incorrect 112 ms 56136 KB Output isn't correct
86 Incorrect 175 ms 56248 KB Output isn't correct
87 Incorrect 104 ms 56176 KB Output isn't correct
88 Correct 126 ms 56148 KB Output is correct
89 Correct 127 ms 56164 KB Output is correct
90 Incorrect 66 ms 36020 KB Output isn't correct
91 Incorrect 131 ms 56140 KB Output isn't correct
92 Incorrect 143 ms 56072 KB Output isn't correct
93 Incorrect 186 ms 56164 KB Output isn't correct
94 Correct 136 ms 56140 KB Output is correct
95 Incorrect 114 ms 56148 KB Output isn't correct
96 Correct 113 ms 56280 KB Output is correct
97 Incorrect 186 ms 56128 KB Output isn't correct
98 Incorrect 120 ms 56168 KB Output isn't correct
99 Incorrect 136 ms 56172 KB Output isn't correct
100 Incorrect 168 ms 56064 KB Output isn't correct