# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |