답안 #706001

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706001 2023-03-05T18:20:38 Z KiriLL1ca Bomb (IZhO17_bomb) C++17
40 / 100
1000 ms 58732 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 N = 2505;

string a[N];
int p[N][N];

inline int get (int x, int y, int xx, int yy) {
    int res = p[xx][yy];
    if (x) res -= p[x - 1][yy];
    if (y) res -= p[xx][y - 1];
    if (x && y) res += p[x - 1][y - 1];
    return res;
}

inline bool bad (int s, int t, int n, int m) {
    vector <vector <int>> f (n + 1, vector <int> (m + 1));

    for (int i = 0; i + s - 1 < n; ++i) {
        for (int j = 0; j + t - 1 < m; ++j) {
            if (get(i, j, i + s - 1, j + t - 1) == s * t) {
                ++f[i][j];
                --f[i + s][j];
                --f[i][j + t];
                ++f[i + s][j + t];
            }
        }
    }

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            if (i) f[i][j] += f[i - 1][j];
            if (j) f[i][j] += f[i][j - 1];
            if (i && j) f[i][j] -= f[i - 1][j - 1];
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (a[i][j] == '1' && !f[i][j]) return 1;
        }
    }
    return 0;
}


inline void solve () {
    int n, m; cin >> n >> m;
    for (int i = 0; i < n; ++i) cin >> a[i];

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (i) p[i][j] += p[i - 1][j];
            if (j) p[i][j] += p[i][j - 1];
            if (i && j) p[i][j] -= p[i - 1][j - 1];
            p[i][j] += (a[i][j] - '0');
        }
    }

    int ans = 0, j = m;
    for (int i = 1; i <= n; ++i) {
        while (j) {
            if (bad(i, j, n, m)) --j;
            else break;
        }
        umax(ans, i * j);
    }
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 13 ms 10580 KB Output is correct
4 Correct 17 ms 10588 KB Output is correct
5 Correct 64 ms 340 KB Output is correct
6 Correct 9 ms 424 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 408 KB Output is correct
17 Correct 3 ms 596 KB Output is correct
18 Correct 3 ms 672 KB Output is correct
19 Correct 6 ms 852 KB Output is correct
20 Correct 7 ms 852 KB Output is correct
21 Correct 4 ms 596 KB Output is correct
22 Correct 6 ms 664 KB Output is correct
23 Correct 11 ms 852 KB Output is correct
24 Correct 6 ms 724 KB Output is correct
25 Correct 12 ms 852 KB Output is correct
26 Correct 10 ms 912 KB Output is correct
27 Correct 172 ms 2384 KB Output is correct
28 Correct 307 ms 2712 KB Output is correct
29 Correct 424 ms 3224 KB Output is correct
30 Correct 795 ms 4044 KB Output is correct
31 Correct 594 ms 3300 KB Output is correct
32 Correct 588 ms 3708 KB Output is correct
33 Correct 950 ms 4336 KB Output is correct
34 Correct 153 ms 2680 KB Output is correct
35 Correct 740 ms 4228 KB Output is correct
36 Correct 950 ms 4264 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Execution timed out 1077 ms 57404 KB Time limit exceeded
39 Correct 1 ms 404 KB Output is correct
40 Execution timed out 1064 ms 11340 KB Time limit exceeded
41 Correct 1 ms 468 KB Output is correct
42 Correct 13 ms 800 KB Output is correct
43 Execution timed out 1051 ms 57836 KB Time limit exceeded
44 Execution timed out 1075 ms 4248 KB Time limit exceeded
45 Execution timed out 1032 ms 57808 KB Time limit exceeded
46 Execution timed out 1058 ms 57876 KB Time limit exceeded
47 Execution timed out 1044 ms 57696 KB Time limit exceeded
48 Execution timed out 1010 ms 57404 KB Time limit exceeded
49 Execution timed out 1051 ms 57436 KB Time limit exceeded
50 Execution timed out 1096 ms 57436 KB Time limit exceeded
51 Execution timed out 1008 ms 57432 KB Time limit exceeded
52 Execution timed out 1034 ms 57428 KB Time limit exceeded
53 Execution timed out 1094 ms 57488 KB Time limit exceeded
54 Execution timed out 1103 ms 57500 KB Time limit exceeded
55 Execution timed out 1093 ms 57516 KB Time limit exceeded
56 Execution timed out 1024 ms 57488 KB Time limit exceeded
57 Execution timed out 1041 ms 57400 KB Time limit exceeded
58 Execution timed out 1103 ms 57872 KB Time limit exceeded
59 Execution timed out 1024 ms 58220 KB Time limit exceeded
60 Execution timed out 1076 ms 58704 KB Time limit exceeded
61 Execution timed out 1077 ms 58648 KB Time limit exceeded
62 Execution timed out 1062 ms 58652 KB Time limit exceeded
63 Execution timed out 1076 ms 58688 KB Time limit exceeded
64 Execution timed out 1024 ms 58692 KB Time limit exceeded
65 Execution timed out 1090 ms 58732 KB Time limit exceeded
66 Execution timed out 1040 ms 58656 KB Time limit exceeded
67 Execution timed out 1043 ms 58056 KB Time limit exceeded
68 Execution timed out 1059 ms 57608 KB Time limit exceeded
69 Execution timed out 1053 ms 57584 KB Time limit exceeded
70 Execution timed out 1051 ms 41188 KB Time limit exceeded
71 Execution timed out 1055 ms 57676 KB Time limit exceeded
72 Execution timed out 1022 ms 57968 KB Time limit exceeded
73 Execution timed out 1047 ms 57752 KB Time limit exceeded
74 Execution timed out 1067 ms 57804 KB Time limit exceeded
75 Execution timed out 1057 ms 57632 KB Time limit exceeded
76 Execution timed out 1067 ms 57256 KB Time limit exceeded
77 Execution timed out 1052 ms 57196 KB Time limit exceeded
78 Execution timed out 1052 ms 57148 KB Time limit exceeded
79 Execution timed out 1060 ms 57056 KB Time limit exceeded
80 Execution timed out 1070 ms 57072 KB Time limit exceeded
81 Execution timed out 1059 ms 57056 KB Time limit exceeded
82 Execution timed out 1064 ms 57080 KB Time limit exceeded
83 Execution timed out 1052 ms 57140 KB Time limit exceeded
84 Execution timed out 1059 ms 57060 KB Time limit exceeded
85 Execution timed out 1018 ms 57084 KB Time limit exceeded
86 Execution timed out 1102 ms 57188 KB Time limit exceeded
87 Execution timed out 1078 ms 57324 KB Time limit exceeded
88 Execution timed out 1048 ms 57372 KB Time limit exceeded
89 Execution timed out 1048 ms 57144 KB Time limit exceeded
90 Execution timed out 1058 ms 41156 KB Time limit exceeded
91 Execution timed out 1057 ms 57272 KB Time limit exceeded
92 Execution timed out 1079 ms 57108 KB Time limit exceeded
93 Execution timed out 1063 ms 56952 KB Time limit exceeded
94 Execution timed out 1069 ms 56592 KB Time limit exceeded
95 Execution timed out 1074 ms 56432 KB Time limit exceeded
96 Execution timed out 1078 ms 56348 KB Time limit exceeded
97 Execution timed out 1090 ms 56236 KB Time limit exceeded
98 Execution timed out 1079 ms 56420 KB Time limit exceeded
99 Execution timed out 1083 ms 56216 KB Time limit exceeded
100 Execution timed out 1071 ms 56544 KB Time limit exceeded