Submission #706318

# Submission time Handle Problem Language Result Execution time Memory
706318 2023-03-06T09:25:38 Z KiriLL1ca Bomb (IZhO17_bomb) C++17
0 / 100
233 ms 62292 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 j = 0; j < m; ++j) {
//            cout << p[i][j] << " ";
//        }
//        cout << endl;
//    }
//    cout << endl;
//    for (int i = 0; i < n; ++i) {
//        for (int j = 0; j < m; ++j) {
//            cout << s[i][j] << " ";
//        }
//        cout << endl;
//    }

    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]);
        cout << mx[i] << " " << i << endl;
        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 1 ms 320 KB Output isn't correct
2 Runtime error 1 ms 468 KB Execution killed with signal 6
3 Runtime error 2 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 340 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 Incorrect 1 ms 212 KB Output isn't correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Incorrect 1 ms 212 KB Output isn't correct
13 Runtime error 1 ms 468 KB Execution killed with signal 6
14 Incorrect 1 ms 212 KB Output isn't correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Incorrect 1 ms 212 KB Output isn't correct
17 Incorrect 1 ms 340 KB Output isn't correct
18 Runtime error 1 ms 576 KB Execution killed with signal 6
19 Runtime error 1 ms 596 KB Execution killed with signal 6
20 Runtime error 1 ms 592 KB Execution killed with signal 6
21 Incorrect 1 ms 340 KB Output isn't correct
22 Incorrect 0 ms 340 KB Output isn't correct
23 Incorrect 1 ms 428 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 3 ms 2004 KB Execution killed with signal 6
28 Incorrect 3 ms 1360 KB Output isn't correct
29 Runtime error 5 ms 2884 KB Execution killed with signal 6
30 Incorrect 4 ms 2132 KB Output isn't correct
31 Incorrect 3 ms 1744 KB Output isn't correct
32 Runtime error 5 ms 3516 KB Execution killed with signal 6
33 Incorrect 3 ms 2308 KB Output isn't correct
34 Runtime error 3 ms 2124 KB Execution killed with signal 6
35 Incorrect 4 ms 2252 KB Output isn't correct
36 Incorrect 5 ms 2308 KB Output isn't correct
37 Incorrect 1 ms 212 KB Output isn't correct
38 Incorrect 199 ms 56424 KB Output isn't correct
39 Incorrect 1 ms 212 KB Output isn't correct
40 Incorrect 44 ms 7492 KB Output isn't correct
41 Incorrect 1 ms 212 KB Output isn't correct
42 Incorrect 1 ms 340 KB Output isn't correct
43 Incorrect 163 ms 56420 KB Output isn't correct
44 Incorrect 3 ms 2308 KB Output isn't correct
45 Incorrect 153 ms 56468 KB Output isn't correct
46 Incorrect 166 ms 56416 KB Output isn't correct
47 Incorrect 166 ms 56416 KB Output isn't correct
48 Incorrect 157 ms 56424 KB Output isn't correct
49 Incorrect 229 ms 56424 KB Output isn't correct
50 Incorrect 164 ms 56356 KB Output isn't correct
51 Incorrect 161 ms 56420 KB Output isn't correct
52 Incorrect 164 ms 56436 KB Output isn't correct
53 Incorrect 164 ms 56416 KB Output isn't correct
54 Incorrect 130 ms 56420 KB Output isn't correct
55 Incorrect 120 ms 56420 KB Output isn't correct
56 Incorrect 212 ms 56424 KB Output isn't correct
57 Incorrect 136 ms 56348 KB Output isn't correct
58 Incorrect 129 ms 56420 KB Output isn't correct
59 Incorrect 122 ms 56420 KB Output isn't correct
60 Incorrect 151 ms 56420 KB Output isn't correct
61 Incorrect 233 ms 56420 KB Output isn't correct
62 Incorrect 213 ms 56420 KB Output isn't correct
63 Incorrect 211 ms 56420 KB Output isn't correct
64 Incorrect 126 ms 56300 KB Output isn't correct
65 Incorrect 160 ms 56168 KB Output isn't correct
66 Incorrect 158 ms 56160 KB Output isn't correct
67 Incorrect 166 ms 56164 KB Output isn't correct
68 Incorrect 168 ms 56124 KB Output isn't correct
69 Incorrect 125 ms 56160 KB Output isn't correct
70 Incorrect 56 ms 36052 KB Output isn't correct
71 Incorrect 110 ms 56168 KB Output isn't correct
72 Incorrect 119 ms 56164 KB Output isn't correct
73 Incorrect 118 ms 56164 KB Output isn't correct
74 Incorrect 142 ms 56168 KB Output isn't correct
75 Incorrect 134 ms 56164 KB Output isn't correct
76 Incorrect 130 ms 56164 KB Output isn't correct
77 Incorrect 122 ms 56176 KB Output isn't correct
78 Incorrect 132 ms 62248 KB Output isn't correct
79 Incorrect 64 ms 62276 KB Output isn't correct
80 Incorrect 89 ms 62280 KB Output isn't correct
81 Incorrect 67 ms 62292 KB Output isn't correct
82 Incorrect 101 ms 62284 KB Output isn't correct
83 Incorrect 122 ms 62212 KB Output isn't correct
84 Incorrect 69 ms 62280 KB Output isn't correct
85 Incorrect 106 ms 62176 KB Output isn't correct
86 Incorrect 172 ms 62276 KB Output isn't correct
87 Incorrect 113 ms 62200 KB Output isn't correct
88 Incorrect 133 ms 62280 KB Output isn't correct
89 Incorrect 143 ms 62256 KB Output isn't correct
90 Incorrect 92 ms 39868 KB Output isn't correct
91 Incorrect 143 ms 62284 KB Output isn't correct
92 Incorrect 141 ms 62284 KB Output isn't correct
93 Incorrect 183 ms 62280 KB Output isn't correct
94 Incorrect 133 ms 62280 KB Output isn't correct
95 Incorrect 126 ms 62280 KB Output isn't correct
96 Incorrect 116 ms 62272 KB Output isn't correct
97 Incorrect 219 ms 62184 KB Output isn't correct
98 Incorrect 120 ms 62276 KB Output isn't correct
99 Incorrect 143 ms 62228 KB Output isn't correct
100 Incorrect 175 ms 62248 KB Output isn't correct