Submission #706338

# Submission time Handle Problem Language Result Execution time Memory
706338 2023-03-06T09:43:19 Z KiriLL1ca Bomb (IZhO17_bomb) C++17
0 / 100
751 ms 57448 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);

    for (int iter = 0; iter < 2; ++iter) {
        vec <vec <int>> p (n, vec <int> (m)), s (n, vec <int> (m));
        for (int j = 0; j < m; ++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) umax(mx[1], p[i][j] + s[i][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;
            }
        }

        for (auto &i : a) reverse(all(i));
    }

    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 212 KB Output isn't correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Incorrect 1 ms 596 KB Output isn't correct
4 Incorrect 2 ms 596 KB Output isn't correct
5 Incorrect 1 ms 340 KB Output isn't correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Incorrect 0 ms 212 KB Output isn't correct
11 Incorrect 0 ms 224 KB Output isn't correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Incorrect 0 ms 212 KB Output isn't correct
14 Incorrect 0 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 Incorrect 1 ms 340 KB Output isn't correct
19 Incorrect 1 ms 340 KB Output isn't correct
20 Incorrect 1 ms 340 KB Output isn't correct
21 Incorrect 1 ms 340 KB Output isn't correct
22 Incorrect 1 ms 340 KB Output isn't correct
23 Incorrect 1 ms 340 KB Output isn't correct
24 Incorrect 1 ms 340 KB Output isn't correct
25 Incorrect 1 ms 340 KB Output isn't correct
26 Incorrect 1 ms 340 KB Output isn't correct
27 Incorrect 2 ms 980 KB Output isn't correct
28 Incorrect 3 ms 1240 KB Output isn't correct
29 Incorrect 3 ms 1380 KB Output isn't correct
30 Incorrect 4 ms 2004 KB Output isn't correct
31 Incorrect 4 ms 1620 KB Output isn't correct
32 Incorrect 4 ms 1748 KB Output isn't correct
33 Incorrect 5 ms 2132 KB Output isn't correct
34 Incorrect 2 ms 1040 KB Output isn't correct
35 Incorrect 4 ms 2132 KB Output isn't correct
36 Incorrect 6 ms 2132 KB Output isn't correct
37 Incorrect 0 ms 212 KB Output isn't correct
38 Incorrect 551 ms 56164 KB Output isn't correct
39 Incorrect 1 ms 212 KB Output isn't correct
40 Incorrect 47 ms 7240 KB Output isn't correct
41 Incorrect 0 ms 212 KB Output isn't correct
42 Incorrect 1 ms 340 KB Output isn't correct
43 Incorrect 501 ms 56288 KB Output isn't correct
44 Incorrect 7 ms 2132 KB Output isn't correct
45 Incorrect 467 ms 56164 KB Output isn't correct
46 Incorrect 471 ms 56168 KB Output isn't correct
47 Incorrect 524 ms 56200 KB Output isn't correct
48 Incorrect 473 ms 56204 KB Output isn't correct
49 Incorrect 572 ms 56268 KB Output isn't correct
50 Incorrect 527 ms 56200 KB Output isn't correct
51 Incorrect 515 ms 56152 KB Output isn't correct
52 Incorrect 506 ms 56168 KB Output isn't correct
53 Incorrect 478 ms 56200 KB Output isn't correct
54 Incorrect 483 ms 56160 KB Output isn't correct
55 Incorrect 457 ms 56188 KB Output isn't correct
56 Incorrect 592 ms 56168 KB Output isn't correct
57 Incorrect 450 ms 56164 KB Output isn't correct
58 Incorrect 462 ms 56164 KB Output isn't correct
59 Incorrect 453 ms 56172 KB Output isn't correct
60 Incorrect 477 ms 56164 KB Output isn't correct
61 Incorrect 694 ms 56168 KB Output isn't correct
62 Incorrect 582 ms 56160 KB Output isn't correct
63 Incorrect 572 ms 56160 KB Output isn't correct
64 Incorrect 445 ms 56168 KB Output isn't correct
65 Incorrect 478 ms 56164 KB Output isn't correct
66 Incorrect 508 ms 56260 KB Output isn't correct
67 Incorrect 516 ms 56164 KB Output isn't correct
68 Incorrect 544 ms 56264 KB Output isn't correct
69 Incorrect 449 ms 56256 KB Output isn't correct
70 Incorrect 239 ms 36064 KB Output isn't correct
71 Incorrect 433 ms 56160 KB Output isn't correct
72 Incorrect 462 ms 56164 KB Output isn't correct
73 Incorrect 542 ms 56160 KB Output isn't correct
74 Incorrect 489 ms 56068 KB Output isn't correct
75 Incorrect 462 ms 56164 KB Output isn't correct
76 Incorrect 524 ms 56240 KB Output isn't correct
77 Incorrect 467 ms 56076 KB Output isn't correct
78 Incorrect 501 ms 56160 KB Output isn't correct
79 Incorrect 436 ms 56160 KB Output isn't correct
80 Incorrect 417 ms 56164 KB Output isn't correct
81 Incorrect 446 ms 56168 KB Output isn't correct
82 Incorrect 505 ms 56164 KB Output isn't correct
83 Incorrect 524 ms 56164 KB Output isn't correct
84 Incorrect 393 ms 56164 KB Output isn't correct
85 Incorrect 489 ms 56228 KB Output isn't correct
86 Incorrect 608 ms 56160 KB Output isn't correct
87 Incorrect 457 ms 56164 KB Output isn't correct
88 Incorrect 608 ms 56160 KB Output isn't correct
89 Incorrect 689 ms 56164 KB Output isn't correct
90 Incorrect 348 ms 36072 KB Output isn't correct
91 Incorrect 476 ms 56172 KB Output isn't correct
92 Incorrect 551 ms 56160 KB Output isn't correct
93 Incorrect 612 ms 56164 KB Output isn't correct
94 Incorrect 528 ms 56168 KB Output isn't correct
95 Incorrect 549 ms 56164 KB Output isn't correct
96 Incorrect 582 ms 56428 KB Output isn't correct
97 Incorrect 722 ms 56932 KB Output isn't correct
98 Incorrect 614 ms 57192 KB Output isn't correct
99 Incorrect 610 ms 57444 KB Output isn't correct
100 Incorrect 751 ms 57448 KB Output isn't correct