# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
93322 | toloraia | Bomb (IZhO17_bomb) | C++14 | 1099 ms | 57752 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>
#define ll long long
#define F first
#define S second
#pragma GCC ("O3")
using namespace std;
const int N = 2600;
int n, m;
char ch[N][N];
int A[N][N], B[N][N];
int main()
{
ios::sync_with_stdio(false);
cin>>n>>m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin>>ch[i][j];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
A[i][j] = A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1] + ch[i][j] - '0';
int J = m;
int ans = 0;
for (int I = 1; I <= n && I * J >= ans; I++){
while (J){
bool ok = 1;
for (int i = 0; i <= n; i++)
for (int j = 0; j <= m; j++)
B[i][j] = 0;
for (int i = 0; i + I <= n; i++)
for (int j = 0; j + J <= m; j++){
int x = A[i + I][j + J] - A[i + I][j] - A[i][j + J] + A[i][j];
if (x == I * J){
B[i + I + 1][j + J + 1]++;
B[i + 1][j + J + 1]--;
B[i + I + 1][j + 1]--;
B[i + 1][j + 1]++;
}
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
B[i][j] += B[i - 1][j] + B[i][j - 1] - B[i - 1][j - 1];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (ch[i][j] == '1' && B[i][j] == 0)
ok = 0;
if (ok)
break;
J--;
}
ans = max (ans, I * J);
}
cout<<ans<<endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |