# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
519058 | Dasha_Gnedko | Bomb (IZhO17_bomb) | C++17 | 1104 ms | 61064 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |