# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
119238 | tmwilliamlin168 | Bomb (IZhO17_bomb) | C++14 | 494 ms | 62380 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;
const int mxN=2500;
int n, m, mxw=mxN, mxh=mxN, u[mxN][mxN], d[mxN][mxN], a[mxN], ans;
string g[mxN];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i=0; i<n; ++i) {
cin >> g[i];
for(int j=0, w=0; j<m; ++j) {
w=g[i][j]&1?w+1:0;
if(w&&(j+1>=m||g[i][j+1]&1^1))
mxw=min(w, mxw);
}
}
for(int j=0; j<m; ++j) {
for(int i=0, h=0; i<n; ++i) {
h=g[i][j]&1?h+1:0;
if(h&&(i+1>=n||g[i+1][j]&1^1))
mxh=min(h, mxh);
u[i][j]=i&&g[i-1][j]&1?u[i-1][j]:i;
}
for(int i=n-1; ~i; --i)
d[i][j]=i<n-1&&g[i+1][j]&1?d[i+1][j]:i;
}
for(int i=0; i<mxw; ++i)
a[i]=mxh;
auto c=[]() {
for(int i=0; i<n; ++i) {
for(int j=0; j<m; ++j) {
if(j&&g[i][j-1]&1||g[i][j]&1^1)
continue;
for(int k=0, l=0, r=n; k<mxw; ++k) {
l=max(u[i][j+k], l);
r=min(d[i][j+k], r);
a[k]=min(r-l+1, a[k]);
}
}
}
};
c();
for(int i=0; i<n; ++i) {
reverse(g[i].begin(), g[i].end());
reverse(u[i], u[i]+m);
reverse(d[i], d[i]+m);
}
c();
for(int i=0; i<mxw; ++i)
ans=max((i+1)*a[i], ans);
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |