Submission #833453

#TimeUsernameProblemLanguageResultExecution timeMemory
833453vjudge1Bomb (IZhO17_bomb)C++17
24 / 100
137 ms24912 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// using ld = long double;
#define all(x) begin(x), end(x)
#ifdef LOCAL
#define debug(...) __VA_ARGS__;
#else
#define debug(...)
#endif

template<class A, class B> ostream& operator<<(ostream& os, const pair<A, B> &p);
template<class T> ostream& operator<<(ostream& os, const vector<T> &v);
template<class T, size_t N> ostream& operator<<(ostream& os, const array<T, N> &v);

template<class A, class B>
ostream& operator<<(ostream& os, const pair<A, B> &p) {
  return os << '(' << p.first << ',' << p.second << ')';
}
 
template<class T>
ostream& operator<<(ostream& os, const vector<T> &v) {
  os << '{'; bool fs = 1;
  for(auto &i : v) { if(!fs) os << ','; os << i; fs = 0; }
  return os << '}';
}

template<class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N> &v) {
  os << '{'; bool fs = 1;
  for(auto &i : v) { if(!fs) os << ','; os << i; fs = 0; }
  return os << '}';
}

void init() {
}
 
void solve(int tt = 0) {
  int n, m; cin >> n >> m;
  vector a(n, vector<int>(m));
  bool ok = 0;
  for(auto &v : a) for(int &i : v) {
    char c; cin >> c;
    i = c - '0';
    ok |= i;
  }
  if(!ok) return void(cout << 0 << '\n');
  const int INF = 1e9;
  int h = INF, w = INF;
  {
    for(int i = 0; i < n; i++) {
      int cur = 0;
      for(int j = 0; j < m; j++) {
        if(a[i][j] == 0) {
          if(cur != 0) w = min(w, cur);
          cur = 0;
        } else {
          cur++;
        }
      }
      if(cur != 0) w = min(w, cur);
    }
  }
  {
    for(int j = 0; j < m; j++) {
      int cur = 0;
      for(int i = 0; i < n; i++) {
        if(a[i][j] == 0) {
          if(cur != 0) h = min(h, cur);
          cur = 0;
        } else {
          cur++;
        }
      }
      if(cur != 0) h = min(h, cur);
    }
  }
  debug(cerr << h << ' ' << w << '\n');
  if(h != INF && w != INF) cout << (ll)h * w << '\n';
  else cout << 0 << '\n';
}

void reset() {
}
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int t = 1; // cin >> t;
  init();
  for(int i = 1; i <= t; i++) solve(i), reset();
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...