제출 #1126375

#제출 시각아이디문제언어결과실행 시간메모리
1126375hqminhuwuBomb (IZhO17_bomb)C++17
10 / 100
236 ms104952 KiB
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef long double ld; typedef vector <int> vi; typedef pair <ll,ll> pll; typedef pair <int,int> pii; typedef pair <int,pii> piii; #define forr(_a,_b,_c) for(int _a = (_b); _a <= int (_c); ++_a) #define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> int (_c);) #define forf(_a,_b,_c) for(int _a = (_b); _a < int (_c); ++_a) #define st first #define nd second #define pb push_back #define mp make_pair #define all(x) begin(x),end(x) #define mask(i) (1LL << (i)) #define bit(x, i) (((x) >> (i)) & 1) #define bp __builtin_popcountll #define file "test" template<class X, class Y> bool minz(X &x, const Y &y) { if (x > y) { x = y; return true; } return false; } template<class X, class Y> bool maxz(X &x, const Y &y) { if (x < y) { x = y; return true; } return false; } const int N = 25e2 + 5; const ll oo = (ll) 1e16; const ll mod = 1e9 + 7; // 998244353; int n, m, l[N][N], r[N][N], u[N][N], d[N][N]; string s[N]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; forr (i, 1, n){ cin >> s[i]; s[i] = '#' + s[i]; } forr (i, 1, n){ int lst = -mod; forr (j, 1, m){ if (s[i][j] == '0') lst = j; else l[i][j] = lst; } lst = mod; ford (j, m, 1){ if (s[i][j] == '0') lst = j; else r[i][j] = lst; } } forr (j, 1, m){ int lst = -mod; forr (i, 1, n){ if (s[i][j] == '0') lst = i; else u[i][j] = lst; } lst = mod; ford (i, n, 1){ if (s[i][j] == '0') lst = i; else d[i][j] = lst; } } int h = n, w = m; forr (i, 1, n){ forr (j, 1, m){ if (s[i][j] == '1'){ minz(h, d[i][j] - u[i][j] - 1); minz(w, r[i][j] - l[i][j] - 1); } } } cout << w * h << "\n"; return 0; } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...