Submission #947393

# Submission time Handle Problem Language Result Execution time Memory
947393 2024-03-16T05:48:22 Z Pring Bomb (IZhO17_bomb) C++17
41 / 100
1000 ms 62468 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

// #define int long long
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;

const int MXN = 2505;
int n, m;
string s[MXN];

struct P {
    int n, m, a[MXN][MXN];

    void init(int _n, int _m) {
        n = _n;
        m = _m;
        FOR(i, 0, n + 1) FOR(j, 0, m + 1) a[i][j] = 0;
    }

    void BUILD() {
        FOR(i, 1, n + 1) FOR(j, 1, m + 1) a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
    }
    
    int get(int l, int r, int u, int d) {
        return a[r][d] - a[l][d] - a[r][u] + a[l][u];
    }
};

P fld, R;

void MAKE_P() {
    fld.init(n, m);
    FOR(i, 0, n) FOR(j, 0, m) {
        fld.a[i + 1][j + 1] = (s[i][j] - '0');
    }
    fld.BUILD();
}

bool AC(int h, int w) {
    R.init(n + 1, m + 1);
    FOR(i, 0, n - h + 1) FOR(j, 0, m - w + 1) {
        if (fld.get(i, i + h, j, j + w) == h * w) {
            // debug(i, j);
            R.a[i + 1][j + 1]++;
            R.a[i + h + 1][j + 1]--;
            R.a[i + 1][j + w + 1]--;
            R.a[i + h + 1][j + w + 1]++;
        }
    }
    // FOR(i, 0, n + 1) {
    //     FOR(j, 0, m + 1) cout << R.a[i][j] << ' ';
    //     cout << '\n';
    // }
    // cout << endl;
    R.BUILD();
    // FOR(i, 0, n + 1) {
    //     FOR(j, 0, m + 1) cout << R.a[i][j] << ' ';
    //     cout << '\n';
    // }
    // cout << endl;
    int sum = 0;
    FOR(i, 1, n + 1) FOR(j, 1, m + 1) {
        sum += (R.a[i][j] != 0);
    }
    // debug(h, w, sum == fld.a[n][m]);
    return (sum == fld.a[n][m]);
}

int solve() {
    int w = m, ans = 0;
    FOR(h, 1, n + 1) {
        while (w && !AC(h, w)) w--;
        if (w == 0) return ans;
        ans = max(ans, h * w);
    }
    return ans;
}

void miku() {
    cin >> n >> m;
    FOR(i, 0, n) cin >> s[i];
    MAKE_P();
    cout << solve() << '\n';
    // AC(1, 1);
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    miku();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 13 ms 41256 KB Output is correct
4 Correct 9 ms 42332 KB Output is correct
5 Correct 41 ms 2604 KB Output is correct
6 Correct 7 ms 2740 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 4696 KB Output is correct
16 Correct 1 ms 4700 KB Output is correct
17 Correct 2 ms 6748 KB Output is correct
18 Correct 2 ms 6748 KB Output is correct
19 Correct 4 ms 6748 KB Output is correct
20 Correct 4 ms 6744 KB Output is correct
21 Correct 3 ms 6748 KB Output is correct
22 Correct 4 ms 6748 KB Output is correct
23 Correct 6 ms 6748 KB Output is correct
24 Correct 3 ms 6748 KB Output is correct
25 Correct 7 ms 6748 KB Output is correct
26 Correct 5 ms 6748 KB Output is correct
27 Correct 87 ms 10844 KB Output is correct
28 Correct 163 ms 11100 KB Output is correct
29 Correct 208 ms 11124 KB Output is correct
30 Correct 386 ms 11264 KB Output is correct
31 Correct 315 ms 11196 KB Output is correct
32 Correct 294 ms 11096 KB Output is correct
33 Correct 474 ms 15196 KB Output is correct
34 Correct 74 ms 10844 KB Output is correct
35 Correct 362 ms 15400 KB Output is correct
36 Correct 433 ms 15400 KB Output is correct
37 Correct 1 ms 4696 KB Output is correct
38 Execution timed out 1086 ms 62224 KB Time limit exceeded
39 Correct 1 ms 4952 KB Output is correct
40 Execution timed out 1040 ms 24664 KB Time limit exceeded
41 Correct 1 ms 4696 KB Output is correct
42 Correct 7 ms 6696 KB Output is correct
43 Execution timed out 1024 ms 62220 KB Time limit exceeded
44 Correct 524 ms 15400 KB Output is correct
45 Execution timed out 1042 ms 62288 KB Time limit exceeded
46 Execution timed out 1008 ms 62140 KB Time limit exceeded
47 Execution timed out 1018 ms 62292 KB Time limit exceeded
48 Execution timed out 1036 ms 62188 KB Time limit exceeded
49 Execution timed out 1018 ms 62236 KB Time limit exceeded
50 Execution timed out 1091 ms 62288 KB Time limit exceeded
51 Execution timed out 1092 ms 62224 KB Time limit exceeded
52 Execution timed out 1047 ms 62292 KB Time limit exceeded
53 Execution timed out 1044 ms 62292 KB Time limit exceeded
54 Execution timed out 1044 ms 62292 KB Time limit exceeded
55 Execution timed out 1018 ms 62328 KB Time limit exceeded
56 Execution timed out 1006 ms 62288 KB Time limit exceeded
57 Execution timed out 1040 ms 62160 KB Time limit exceeded
58 Execution timed out 1088 ms 62136 KB Time limit exceeded
59 Execution timed out 1012 ms 62288 KB Time limit exceeded
60 Execution timed out 1041 ms 62292 KB Time limit exceeded
61 Execution timed out 1010 ms 62128 KB Time limit exceeded
62 Execution timed out 1072 ms 62288 KB Time limit exceeded
63 Execution timed out 1022 ms 62140 KB Time limit exceeded
64 Execution timed out 1029 ms 62144 KB Time limit exceeded
65 Execution timed out 1035 ms 62252 KB Time limit exceeded
66 Execution timed out 1044 ms 62140 KB Time limit exceeded
67 Execution timed out 1035 ms 62108 KB Time limit exceeded
68 Execution timed out 1088 ms 62236 KB Time limit exceeded
69 Execution timed out 1020 ms 62172 KB Time limit exceeded
70 Execution timed out 1016 ms 50680 KB Time limit exceeded
71 Execution timed out 1030 ms 62148 KB Time limit exceeded
72 Execution timed out 1006 ms 62204 KB Time limit exceeded
73 Execution timed out 1004 ms 62348 KB Time limit exceeded
74 Execution timed out 1043 ms 62292 KB Time limit exceeded
75 Execution timed out 1006 ms 62288 KB Time limit exceeded
76 Execution timed out 1010 ms 62324 KB Time limit exceeded
77 Execution timed out 1031 ms 62292 KB Time limit exceeded
78 Execution timed out 1035 ms 62292 KB Time limit exceeded
79 Execution timed out 1018 ms 62344 KB Time limit exceeded
80 Execution timed out 1018 ms 62288 KB Time limit exceeded
81 Execution timed out 1084 ms 62212 KB Time limit exceeded
82 Execution timed out 1022 ms 62164 KB Time limit exceeded
83 Execution timed out 1034 ms 62292 KB Time limit exceeded
84 Execution timed out 1033 ms 62136 KB Time limit exceeded
85 Execution timed out 1025 ms 62204 KB Time limit exceeded
86 Execution timed out 1089 ms 62288 KB Time limit exceeded
87 Execution timed out 1026 ms 62312 KB Time limit exceeded
88 Execution timed out 1034 ms 62136 KB Time limit exceeded
89 Execution timed out 1085 ms 62468 KB Time limit exceeded
90 Execution timed out 1035 ms 51704 KB Time limit exceeded
91 Execution timed out 1022 ms 62292 KB Time limit exceeded
92 Execution timed out 1008 ms 62292 KB Time limit exceeded
93 Execution timed out 1010 ms 62292 KB Time limit exceeded
94 Execution timed out 1006 ms 62212 KB Time limit exceeded
95 Execution timed out 1004 ms 62288 KB Time limit exceeded
96 Execution timed out 1026 ms 62292 KB Time limit exceeded
97 Execution timed out 1006 ms 62096 KB Time limit exceeded
98 Execution timed out 1038 ms 62292 KB Time limit exceeded
99 Execution timed out 1033 ms 62120 KB Time limit exceeded
100 Execution timed out 1044 ms 62196 KB Time limit exceeded