Submission #343278

#TimeUsernameProblemLanguageResultExecution timeMemory
343278PetyBomb (IZhO17_bomb)C++14
24 / 100
438 ms56172 KiB
#include <bits/stdc++.h>

using namespace std;

int n, m, w, h, dp[2502][2502], dp2[2502][2502];
char v[2502][2502];

int main()
{
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> v[i][j];
      if (v[i][j] == '1') {
        dp[i][j] = dp[i][j - 1] + 1;
        dp2[i][j] = dp2[i - 1][j] + 1;
      }
    }
  int w = 1e9, h = 1e9;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if ((j == m && v[i][j] == '1') || (v[i][j] == '1' && v[i][j + 1] == '0'))
        w = min(w, dp[i][j]);
      if ((i == n && v[i][j] == '1') || (v[i][j] == '1' && v[i + 1][j] == '0'))
        h = min(h, dp2[i][j]);
    }
  if (h == 1e9)
    cout << "0\n";
  cout << w * h << "\n";
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...