Submission #1128759

#TimeUsernameProblemLanguageResultExecution timeMemory
1128759kreamBomb (IZhO17_bomb)C++20
12 / 100
45 ms10572 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 3; const int inf = 1e9 + 7; int a[N][N]; pair < int, int > d[N][N]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, m; cin >> n >> m; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ char c; cin >> c; a[i][j] = c - '0'; } } for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(a[i][j] == 0) d[i][j] = {0, 0}; else d[i][j].first = d[i][j - 1].first + 1, d[i][j].second = d[i - 1][j].second + 1; } } int ans1 = N, ans2 = N; for(int i = 1; i <= n; i++){ int cnt = 0; for(int j = m; j >= 1; j--){ if(cnt) cnt--; if(d[i][j].first && !cnt) ans1 = min(ans1, d[i][j].first), cnt = d[i][j].first; } } for(int j = 1; j <= m; j++){ int cnt = 0; for(int i = n; i >= 1; i--){ if(cnt) cnt--; if(d[i][j].second && !cnt) ans2 = min(ans2, d[i][j].second), cnt = d[i][j].second; } } cout << ans1 * ans2; }
#Verdict Execution timeMemoryGrader output
Fetching results...