Submission #399997

# Submission time Handle Problem Language Result Execution time Memory
399997 2021-05-07T03:02:40 Z abc864197532 Bomb (IZhO17_bomb) C++17
19 / 100
205 ms 10400 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define info() cerr << __PRETTY_FUNCTION__ << ": " << __LINE__ << endl
#define test(args...) info(), abc("[" + string(#args) + "]", args)
void abc() {cerr << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
    cerr << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
    while (l != r) cout << *l << " \n"[++l == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
    return o >> a.X >> a.Y;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
    return o << '(' << a.X << ", " << a.Y << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
    bool is = false;
    for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
    return o << '}';
}
const int N = 1000087, logN = 20, K = 111;

int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    string s[n];
    for (int i = 0; i < n; ++i) cin >> s[i];
    vector <int> cnt(m, 0), len(n + 1, 1 << 30);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cnt[j] = s[i][j] == '0' ? 0 : cnt[j] + 1;
        }
        vector <int> l(m), r(m);
        stack <int> stk;
        for (int j = 0; j < m; ++j) {
            if (!stk.empty() && cnt[stk.top()] >= cnt[j]) stk.pop();
            l[j] = stk.empty() ? j + 1 : j - stk.top();
            stk.push(j);
        }
        while (!stk.empty()) stk.pop();
        for (int j = m - 1; ~j; --j) {
            if (!stk.empty() && cnt[stk.top()] >= cnt[j]) stk.pop();
            r[j] = stk.empty() ? m - j : stk.top() - j;
            stk.push(j);
        }
        vector <int> now(n + 1, 1 << 30);
        for (int j = 0; j < m; ++j) if (cnt[j] > 0) {
            now[cnt[j]] = min(now[cnt[j]], l[j] + r[j] - 1);
        }
        int curmn = 1 << 30;
        for (int j = n; ~j; --j) {
            if (now[j] == 1 << 30) now[j] = curmn;
            curmn = min(curmn, now[j]);
        }
        for (int j = 0; j <= n; ++j) len[j] = min(len[j], now[j]);
    }
    int mn = n + 1;
    for (int j = 0; j < m; ++j) {
        int now = 0;
        for (int i = 0; i < n; ++i) {
            if (s[i][j] == '0') {
                if (now > 0) mn = min(mn, now);
                now = 0;
            }
            else now++;
        }
        if (now > 0) mn = min(mn, now);
    }
    if (mn == n + 1) mn = 0;
    int ans = 0;
    for (int i = 1; i <= mn; ++i) ans = max(ans, len[i] * i);
    assert(ans <= n * m);
    cout << ans << endl;
}
/*
5 6
001000
111110
111110
111110
000100
 */
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 17 ms 416 KB Output is correct
4 Correct 17 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Incorrect 1 ms 204 KB Output isn't correct
11 Incorrect 1 ms 204 KB Output isn't correct
12 Correct 1 ms 320 KB Output is correct
13 Incorrect 1 ms 204 KB Output isn't correct
14 Correct 1 ms 320 KB Output is correct
15 Incorrect 1 ms 204 KB Output isn't correct
16 Correct 1 ms 204 KB Output is correct
17 Incorrect 1 ms 324 KB Output isn't correct
18 Incorrect 1 ms 204 KB Output isn't correct
19 Incorrect 2 ms 332 KB Output isn't correct
20 Incorrect 1 ms 332 KB Output isn't correct
21 Incorrect 1 ms 204 KB Output isn't correct
22 Incorrect 1 ms 332 KB Output isn't correct
23 Incorrect 1 ms 332 KB Output isn't correct
24 Incorrect 1 ms 332 KB Output isn't correct
25 Incorrect 1 ms 332 KB Output isn't correct
26 Incorrect 1 ms 324 KB Output isn't correct
27 Incorrect 4 ms 460 KB Output isn't correct
28 Incorrect 4 ms 452 KB Output isn't correct
29 Incorrect 4 ms 588 KB Output isn't correct
30 Incorrect 5 ms 632 KB Output isn't correct
31 Incorrect 5 ms 588 KB Output isn't correct
32 Incorrect 5 ms 660 KB Output isn't correct
33 Incorrect 6 ms 696 KB Output isn't correct
34 Incorrect 4 ms 460 KB Output isn't correct
35 Incorrect 6 ms 712 KB Output isn't correct
36 Incorrect 8 ms 748 KB Output isn't correct
37 Incorrect 1 ms 204 KB Output isn't correct
38 Correct 186 ms 10308 KB Output is correct
39 Incorrect 1 ms 204 KB Output isn't correct
40 Incorrect 21 ms 1868 KB Output isn't correct
41 Incorrect 1 ms 204 KB Output isn't correct
42 Incorrect 1 ms 332 KB Output isn't correct
43 Correct 194 ms 10352 KB Output is correct
44 Incorrect 6 ms 716 KB Output isn't correct
45 Incorrect 189 ms 10260 KB Output isn't correct
46 Correct 184 ms 10324 KB Output is correct
47 Incorrect 191 ms 10308 KB Output isn't correct
48 Incorrect 180 ms 10312 KB Output isn't correct
49 Incorrect 191 ms 10308 KB Output isn't correct
50 Incorrect 186 ms 10312 KB Output isn't correct
51 Incorrect 186 ms 10232 KB Output isn't correct
52 Incorrect 183 ms 10308 KB Output isn't correct
53 Incorrect 182 ms 10308 KB Output isn't correct
54 Incorrect 177 ms 10284 KB Output isn't correct
55 Incorrect 171 ms 10308 KB Output isn't correct
56 Correct 189 ms 10332 KB Output is correct
57 Incorrect 164 ms 10316 KB Output isn't correct
58 Incorrect 174 ms 10264 KB Output isn't correct
59 Incorrect 169 ms 10308 KB Output isn't correct
60 Correct 178 ms 10316 KB Output is correct
61 Correct 181 ms 10308 KB Output is correct
62 Correct 180 ms 10316 KB Output is correct
63 Correct 177 ms 10336 KB Output is correct
64 Correct 170 ms 10312 KB Output is correct
65 Incorrect 168 ms 10308 KB Output isn't correct
66 Incorrect 171 ms 10308 KB Output isn't correct
67 Incorrect 172 ms 10312 KB Output isn't correct
68 Incorrect 162 ms 10316 KB Output isn't correct
69 Incorrect 160 ms 10320 KB Output isn't correct
70 Incorrect 98 ms 7744 KB Output isn't correct
71 Incorrect 149 ms 10316 KB Output isn't correct
72 Incorrect 160 ms 10200 KB Output isn't correct
73 Incorrect 171 ms 10400 KB Output isn't correct
74 Incorrect 161 ms 10176 KB Output isn't correct
75 Incorrect 165 ms 10128 KB Output isn't correct
76 Incorrect 176 ms 10100 KB Output isn't correct
77 Incorrect 205 ms 10080 KB Output isn't correct
78 Incorrect 173 ms 10128 KB Output isn't correct
79 Incorrect 167 ms 10112 KB Output isn't correct
80 Incorrect 171 ms 9924 KB Output isn't correct
81 Incorrect 166 ms 9932 KB Output isn't correct
82 Incorrect 178 ms 10044 KB Output isn't correct
83 Incorrect 173 ms 9920 KB Output isn't correct
84 Incorrect 168 ms 9932 KB Output isn't correct
85 Incorrect 173 ms 9932 KB Output isn't correct
86 Incorrect 178 ms 9796 KB Output isn't correct
87 Incorrect 172 ms 9804 KB Output isn't correct
88 Incorrect 175 ms 9804 KB Output isn't correct
89 Incorrect 173 ms 9924 KB Output isn't correct
90 Incorrect 95 ms 7340 KB Output isn't correct
91 Incorrect 171 ms 9796 KB Output isn't correct
92 Incorrect 181 ms 9740 KB Output isn't correct
93 Incorrect 194 ms 9744 KB Output isn't correct
94 Incorrect 179 ms 9744 KB Output isn't correct
95 Incorrect 171 ms 9664 KB Output isn't correct
96 Incorrect 173 ms 9924 KB Output isn't correct
97 Incorrect 182 ms 9804 KB Output isn't correct
98 Incorrect 170 ms 9880 KB Output isn't correct
99 Incorrect 193 ms 9792 KB Output isn't correct
100 Incorrect 182 ms 9656 KB Output isn't correct