제출 #833171

#제출 시각아이디문제언어결과실행 시간메모리
833171vjudge1Bomb (IZhO17_bomb)C++17
24 / 100
180 ms49792 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'); int h = 1e9, w = 1e9; { vector b = a; for(int i = 1; i < n; i++) { for(int j = 0; j < m; j++) { if(b[i][j] != 0) { b[i][j] += b[i-1][j]; } } } debug({ for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) cerr << b[i][j]; cerr << '\n'; } }); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) if(b[i][j] != 0 && (i == n-1 || (i < n-1 && b[i+1][j] == 0))) { h = min(h, b[i][j]); } } } { vector b = a; for(int j = 1; j < m; j++) { for(int i = 0; i < n; i++) { if(b[i][j] != 0) { b[i][j] += b[i][j-1]; } } } debug({ for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) cerr << b[i][j]; cerr << '\n'; } }); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) if(b[i][j] != 0 && (j == m-1 || (j < m-1 && b[i][j+1] == 0))) { w = min(w, b[i][j]); } } } cout << (ll)h * w << '\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...