# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
854632 | The_Samurai | Bomb (IZhO17_bomb) | C++17 | 1095 ms | 31320 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int inf = 1e9, N = 1e6 + 5;
int main() {
cin.tie(0)->sync_with_stdio(false);
#ifdef sunnatov
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
// freopen("bomb.in", "r", stdin);
// freopen("bomb.out", "w", stdout);
#endif
int n, m;
cin >> n >> m;
vector<vector<char>> a(n + 1, vector<char>(m + 1));
vector<vector<int>> pref(n + 1, vector<int>(m + 1));
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) {
cin >> a[i][j];
pref[i][j] = pref[i][j - 1] + pref[i - 1][j] - pref[i - 1][j - 1] + (int) (a[i][j] == '1');
}
auto get_sum = [&](int x1, int y1, int x2, int y2) {
return pref[x2][y2] - pref[x2][y1 - 1] - pref[x1 - 1][y2] + pref[x1 - 1][y1 - 1];
};
auto get = [&](int h) {
int mn = m;
vector<int> last(m + 1, -inf);
for (int i = 1; i <= n; i++) {
int cnt = 0;
for (int j = 1; j <= m; j++) {
if (a[i][j] == '0') {
if (cnt > 0) mn = min(mn, cnt);
cnt = 0;
continue;
}
if (i + h - 1 > n or get_sum(i, j, i + h - 1, j) != h) {
if (i - last[j] >= h) return 0;
continue;
}
last[j] = i;
cnt++;
}
if (cnt > 0) mn = min(mn, cnt);
}
return mn;
};
int ans = 0;
for (int i = 1; i <= n; i++) ans = max(ans, get(i) * i);
cout << (ans == inf ? 0 : ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |