Submission #399971

#TimeUsernameProblemLanguageResultExecution timeMemory
399971syl123456Bomb (IZhO17_bomb)C++17
0 / 100
163 ms55820 KiB
#include <bits/stdc++.h> #define all(i) (i).begin(), (i).end() #define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl using namespace std; template<typename T1, typename T2> ostream& operator << (ostream &i, pair<T1, T2> j) { return i << j.first << ' ' << j.second; } template<typename T> ostream& operator << (ostream &i, vector<T> j) { i << '{' << j.size() << ':'; for (T ii : j) i << ' ' << ii; return i << '}'; } typedef long long ll; typedef pair<int, int> pi; int main() { ios::sync_with_stdio(0), cin.tie(0); int n, m; cin >> n >> m; vector<string> v(n + 2, string(m + 2, '0')); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) cin >> v[i][j]; vector<vector<int>> h(n + 2, vector<int>(m + 2, 0)), w(n + 2, vector<int>(m + 2, 0)); int _h = n, _w = m; for (int i = n; i; --i) for (int j = m; j; --j) if (v[i][j] == '1') { h[i][j] = h[i + 1][j] + 1, w[i][j] = w[i][j + 1] + 1; if (v[i - 1][j] == '0') _h = min(_h, h[i][j]); if (v[i][j - 1] == '0') _w = min(_w, w[i][j]); } return 0; vector<int> lim(_h + 2, _w); for (int i = 1; i <= n; ++i) { pi pre(0, 0); for (int j = 1; j <= m + 1; ++j) { if (v[i - 1][j] == '0' && v[i][j - 1] == '0') { pre = pi(j, h[i][j]); continue; } if (h[i][j] >= pre.second) continue; lim[h[i][j] + 1] = min(lim[h[i][j] + 1], j - pre.first); pre.second = h[i][j]; } } int ans = 0; for (int i = 1; i <= _h; ++i) lim[i] = min(lim[i], lim[i - 1]), ans = max(ans, i * lim[i]); cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...