# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1128455 | _Temirhan | Bomb (IZhO17_bomb) | C++20 | 1104 ms | 124624 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define sz(x) x.size()
#define F first
#define S second
#define nl '\n'
void Tima()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
const int N = 3000;
const int inf = 1e12;
const int mod = 1e9 + 7;
int n, m, p[N][N], p1[N][N];
string t[N];
signed main()
{
// Tima();
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >>n >>m;
for( int i = 0; i < n; ++i )
{
cin >>t[i];
for( int j = 0; j < m; ++j )
if( t[i][j] == '1' )
++p[i + 1][j + 1];
}
for( int i = 1; i <= n; ++i )
for( int j = 1; j <= m; ++j )
p[i][j] += p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1];
int ans = 1;
for( int x = 1; x <= n; ++x )
for( int y = 1; y <= m; ++y )
{
if( x == 1 && y == 1 )
continue;
for( int i = 1; i + x - 1 <= n; ++i )
for( int j = 1; j + y - 1 <= m; ++j )
if( p[i + x - 1][j + y - 1] - p[i + x - 1][j - 1] - p[i - 1][j + y - 1] + p[i - 1][j - 1] == x * y )
{
++p1[i][j];
--p1[i + x][j];
--p1[i][j + y];
++p1[i + x][j + y];
}
bool ch = true;
for( int i = 1; i <= n; ++i )
for( int j = 1; j <= m; ++j )
{
p1[i][j] += p1[i - 1][j] + p1[i][j - 1] - p1[i - 1][j - 1];
if( !p1[i][j] && t[i - 1][j - 1] == '1' )
ch = false;
}
if( ch )
ans = max(ans, x * y);
for( int i = 1; i <= n + 1; ++i )
for( int j = 1; j <= m + 1; ++j )
p1[i][j] = 0;
}
cout <<ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |