# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334315 | beksultan04 | Bomb (IZhO17_bomb) | C++14 | 463 ms | 131076 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 int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e5+12,INF=1e9+7;
int q[2501][2501],dp[N],up[2501][2501],down[2501][2501],ans[N];
main(){
int n,m,i,j,X=INF,Y=INF;
scan2(n,m)
for (i=1;i<=n;++i)
for (j=1;j<=m;++j){
char ch;
cin>>ch;
q[i][j]=ch-'0';
}
for (i=1;i<=n;++i){
for (j=1;j<=m;++j){
if (q[i][j]){
up[i][j] = 1+up[i-1][j];
if (q[i+1][j] == 0)Y = min(Y,up[i][j]);
}
}
}
for (i=n;i>0;--i){
for (j=m;j>0;--j){
if (q[i][j]){
down[i][j] = 1+down[i+1][j];
if (q[i-1][j] == 0)X = min(X,down[i][j]);
}
}
}
/// /// /// ///
for (i=1;i<=Y;++i){
ans[i]=X;
}
for (i=1;i<=n;++i){
int a=INF,b=INF,c=0;
for (j=1;j<=m;++j){
if (q[i][j] == 0){
if (c != 0)
X = min(X,c);
a=b=INF;
c=0;
}
else {
a = min(a,down[i][j]);
b = min(b,up[i][j]);
c++;
ans[c] = min(ans[c],b+a-1);
}
}
}
/// /// /// ///
int mx = 0;
for (i=1;i<=X;++i){
mx = max(mx,ans[i]*i);
}
cout <<mx;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |