# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170167 | dxz05 | Bomb (IZhO17_bomb) | C++14 | 229 ms | 61092 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |