Submission #1055423

#TimeUsernameProblemLanguageResultExecution timeMemory
1055423makravBomb (IZhO17_bomb)C++17
24 / 100
38 ms13564 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() #define pb push_back #define ff first #define sc second void solve() { int n, m; cin >> n >> m; vector<string> s(n); for (int i = 0; i < n; i++) cin >> s[i]; int wg = m, hg = n; for (int i = 0; i < n; i++) { int lf = -1; for (int j = 0; j < m; j++) { if (s[i][j] == '1' && lf == -1) lf = j; else if (s[i][j] == '0' && lf != -1) { wg = min(wg, j - lf); lf = -1; } } if (lf != -1) wg = min(wg, m - lf); } for (int j = 0; j < m; j++) { int lf = -1; for (int i = 0; i < n; i++) { if (s[i][j] == '1' && lf == -1) lf = i; else if (s[i][j] == '0' && lf != -1) { hg = min(hg, i - lf); lf = -1; } } if (lf != -1) hg = min(hg, n - lf); } cout << wg * hg << '\n'; } signed main() { int tt = 1; #ifdef LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); cin >> tt; #else ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #endif while (tt--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...