Submission #170167

#TimeUsernameProblemLanguageResultExecution timeMemory
170167dxz05Bomb (IZhO17_bomb)C++14
11 / 100
229 ms61092 KiB
#include <bits/stdc++.h> using namespace std; #define sqr(x) ((x)*(x)) #define cube(x) ((x)*(x)*(x)) #define GCD(a, b) __gcd(a, b) #define LCM(a, b) ((a)*(b)/GCD(a,b)) #define MP make_pair #define n1 first #define n2 second #define PII pair<int,int> #define PLL pair<ll,ll> #define SI set<int> #define SL set<ll> #define MS multiset #define MSI multiset<int> #define MSLL multiset<ll> #define PB push_back #define PF push_front #define VI vector<int> #define VPI vector<pair<int,int>> #define VLL vector<ll> #define SZ(x) ((int)x.size()) typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef double db; const int INF = 1e9; const int MOD = 1000000007; const int N = 2002055; const int M = 2511; char a[M][M]; int dpx[M][M], dpy[M][M]; void solve() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; if (a[i][j] == '1'){ dpx[i][j] = 1; dpy[i][j] = 1; } } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (a[i][j] == '0') continue; if (a[i][j-1] == '1') dpx[i][j] = dpx[i][j-1]+1; if (a[i-1][j] == '1') dpy[i][j] = dpy[i-1][j]+1; } } for (int i = n; i >= 1; i--){ for (int j = m; j >= 1; j--){ dpx[i][j] = max(dpx[i][j], dpx[i][j+1]); dpy[i][j] = max(dpy[i][j], dpy[i+1][j]); } } int A = INF, B = INF; for (int i = 1; i <= n; i++){ for (int j = 1; j <= m; j++){ if (a[i][j] == '0') continue; A = min(A, dpx[i][j]); B = min(B, dpy[i][j]); } } cout << A*B; } int main() { ios_base::sync_with_stdio(false); #ifdef dxz05 freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else #endif int T = 1; //cin >> T; while (T--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...