Submission #519058

# Submission time Handle Problem Language Result Execution time Memory
519058 2022-01-25T14:15:25 Z Dasha_Gnedko Bomb (IZhO17_bomb) C++17
26 / 100
1000 ms 61064 KB
#include <bits/stdc++.h>

//#include <ext/pb_ds/detail/standard_policies.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

using namespace std;

//using namespace __gnu_pbds;
//template <typename T> using ordered_set = tree <T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 gen(time(0));

#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define sz(a) int32_t(a.size())
#define endl '\n'
//#define int long long

const int N = 3100;
const int M = 31;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 7;

int a[N][N], cnt[N][N], n, m;

bool good(int x, int y)
{
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cnt[i][j] = 0;
    for(int i = 0; i + x <= n; i++)
        for(int j = 0; j + y <= m; j++)
        {
            int fl = 0;
            for(int x1 = i; x1 < i + x; x1++)
            {
                for(int y1 = j; y1 < j + y; y1++)
                {
                    if (!a[x1][y1])
                    {
                        fl = 1;
                        break;
                    }
                }
                if (fl) break;
            }
            if (fl) continue;
            for(int x1 = i; x1 < i + x; x1++)
                for(int y1 = j; y1 < j + y; y1++)
                    cnt[x1][y1] = 1;
        }
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            if (a[i][j] && !cnt[i][j]) return 0;
    return 1;
}

int32_t 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);
#else
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // LOCAL

    cin >> n >> m;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
        {
            char c;
            cin >> c;
            a[i][j] = int32_t(c - '0');
        }
    int x = m, y = n, ls = 0;
    for(int i = 0; i < n; i++)
    {
        ls = -1;
        for(int j = 0; j < m; j++)
        {
            if (!a[i][j])
            {
                if (j && a[i][j - 1]) x = min(x, j - ls - 1);
                ls = j;
            }
        }
        if (ls != m - 1) x = min(x, m - ls - 1);
    }
    for(int j = 0; j < m; j++)
    {
        ls = -1;
        for(int i = 0; i < n; i++)
        {
            if (!a[i][j])
            {
                if (i && a[i - 1][j]) y = min(y, i - ls - 1);
                ls = i;
            }
        }
        if (ls != n - 1) y = min(y, n - ls - 1);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = m; j >= 1; j--)
        {
            if (!good(i, j)) continue;
            ans = max(ans, i * j);
            break;
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Execution timed out 1091 ms 20412 KB Time limit exceeded
4 Execution timed out 1091 ms 20428 KB Time limit exceeded
5 Correct 227 ms 332 KB Output is correct
6 Correct 80 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 2 ms 460 KB Output is correct
17 Correct 28 ms 844 KB Output is correct
18 Correct 14 ms 924 KB Output is correct
19 Correct 85 ms 1236 KB Output is correct
20 Correct 87 ms 1100 KB Output is correct
21 Correct 14 ms 716 KB Output is correct
22 Correct 35 ms 976 KB Output is correct
23 Correct 415 ms 1184 KB Output is correct
24 Correct 76 ms 972 KB Output is correct
25 Correct 679 ms 1180 KB Output is correct
26 Execution timed out 1041 ms 1100 KB Time limit exceeded
27 Execution timed out 1094 ms 3276 KB Time limit exceeded
28 Execution timed out 1090 ms 3404 KB Time limit exceeded
29 Execution timed out 1099 ms 4428 KB Time limit exceeded
30 Execution timed out 1084 ms 5196 KB Time limit exceeded
31 Execution timed out 1051 ms 4044 KB Time limit exceeded
32 Execution timed out 1091 ms 4684 KB Time limit exceeded
33 Execution timed out 1099 ms 5452 KB Time limit exceeded
34 Execution timed out 1099 ms 3788 KB Time limit exceeded
35 Execution timed out 1099 ms 5452 KB Time limit exceeded
36 Execution timed out 1095 ms 5452 KB Time limit exceeded
37 Correct 1 ms 460 KB Output is correct
38 Execution timed out 1088 ms 60928 KB Time limit exceeded
39 Correct 1 ms 460 KB Output is correct
40 Execution timed out 1095 ms 13388 KB Time limit exceeded
41 Correct 1 ms 460 KB Output is correct
42 Execution timed out 1090 ms 1100 KB Time limit exceeded
43 Execution timed out 1091 ms 60864 KB Time limit exceeded
44 Execution timed out 1097 ms 5452 KB Time limit exceeded
45 Execution timed out 1093 ms 61032 KB Time limit exceeded
46 Execution timed out 1093 ms 60952 KB Time limit exceeded
47 Execution timed out 1104 ms 60936 KB Time limit exceeded
48 Execution timed out 1090 ms 60968 KB Time limit exceeded
49 Execution timed out 1078 ms 60964 KB Time limit exceeded
50 Execution timed out 1096 ms 60960 KB Time limit exceeded
51 Execution timed out 1098 ms 60868 KB Time limit exceeded
52 Execution timed out 1102 ms 60860 KB Time limit exceeded
53 Execution timed out 1093 ms 60972 KB Time limit exceeded
54 Execution timed out 1099 ms 60868 KB Time limit exceeded
55 Execution timed out 1098 ms 60868 KB Time limit exceeded
56 Execution timed out 1100 ms 60868 KB Time limit exceeded
57 Execution timed out 1091 ms 60964 KB Time limit exceeded
58 Execution timed out 1088 ms 60868 KB Time limit exceeded
59 Execution timed out 1094 ms 60952 KB Time limit exceeded
60 Execution timed out 1091 ms 60892 KB Time limit exceeded
61 Execution timed out 1095 ms 60892 KB Time limit exceeded
62 Execution timed out 1071 ms 60868 KB Time limit exceeded
63 Execution timed out 1095 ms 60904 KB Time limit exceeded
64 Execution timed out 1094 ms 60988 KB Time limit exceeded
65 Execution timed out 1096 ms 60868 KB Time limit exceeded
66 Execution timed out 1101 ms 60908 KB Time limit exceeded
67 Execution timed out 1098 ms 60868 KB Time limit exceeded
68 Execution timed out 1101 ms 60868 KB Time limit exceeded
69 Execution timed out 1087 ms 60908 KB Time limit exceeded
70 Execution timed out 1101 ms 47580 KB Time limit exceeded
71 Execution timed out 1102 ms 60888 KB Time limit exceeded
72 Execution timed out 1058 ms 60868 KB Time limit exceeded
73 Execution timed out 1091 ms 60864 KB Time limit exceeded
74 Execution timed out 1087 ms 60880 KB Time limit exceeded
75 Execution timed out 1099 ms 60892 KB Time limit exceeded
76 Execution timed out 1092 ms 60868 KB Time limit exceeded
77 Execution timed out 1088 ms 60848 KB Time limit exceeded
78 Execution timed out 1092 ms 60948 KB Time limit exceeded
79 Execution timed out 1096 ms 60864 KB Time limit exceeded
80 Execution timed out 1097 ms 60852 KB Time limit exceeded
81 Execution timed out 1097 ms 60880 KB Time limit exceeded
82 Execution timed out 1096 ms 60856 KB Time limit exceeded
83 Execution timed out 1090 ms 60864 KB Time limit exceeded
84 Execution timed out 1096 ms 60936 KB Time limit exceeded
85 Execution timed out 1096 ms 60868 KB Time limit exceeded
86 Execution timed out 1096 ms 60868 KB Time limit exceeded
87 Execution timed out 1102 ms 60868 KB Time limit exceeded
88 Execution timed out 1076 ms 60948 KB Time limit exceeded
89 Execution timed out 1091 ms 60868 KB Time limit exceeded
90 Execution timed out 1098 ms 47472 KB Time limit exceeded
91 Execution timed out 1091 ms 61064 KB Time limit exceeded
92 Execution timed out 1094 ms 60884 KB Time limit exceeded
93 Execution timed out 1093 ms 60920 KB Time limit exceeded
94 Execution timed out 1098 ms 60868 KB Time limit exceeded
95 Execution timed out 1098 ms 60864 KB Time limit exceeded
96 Execution timed out 1092 ms 60964 KB Time limit exceeded
97 Execution timed out 1094 ms 60916 KB Time limit exceeded
98 Execution timed out 1085 ms 60868 KB Time limit exceeded
99 Execution timed out 1093 ms 60868 KB Time limit exceeded
100 Execution timed out 1088 ms 60948 KB Time limit exceeded