# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
171583 | mcdx9524 | Bomb (IZhO17_bomb) | C++14 | 1088 ms | 18940 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>
using namespace std;
typedef long long ll;
const int N = 2500 + 7;
char a[N][N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
}
}
int ans = 0;
for (int x = 1; x <= n; x++) {
for (int y = 1; y <= m; y++) {
char b[n + 7][m + 7];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
b[i][j] = a[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (i + x - 1 > n || j + y - 1 > m) {
continue;
}
bool bad = false;
for (int r = i; r <= i + x - 1; r++) {
for (int c = j; c <= j + y - 1; c++) {
if (b[r][c] != '1') {
bad = true;
}
if (bad) break;
}
if (bad) break;
}
if (bad) continue;
for (int r = i; r <= i + x - 1; r++) {
for (int c = j; c <= j + y - 1; c++) {
b[r][c] = '2';
}
}
}
}
for (int i = n; i >= 1; i--) {
for (int j = m; j >= 1; j--) {
if (i - x + 1 < 1 || j - y + 1 < 1) {
continue;
}
if (b[i][j] == '1') {
for (int r = i; r >= i - x + 1; r--) {
for (int c = j; c >= j - y + 1; c--) {
b[i][j] = '2';
}
}
}
}
}
bool good = true;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (a[i][j] == '0') {
continue;
}
if (a[i][j] == '1' && b[i][j] == '2') {
continue;
}
good = false;
if (!good) break;
}
if (!good) break;
}
if (good) {
ans = max(ans, x * y);
}
}
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |