# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
936112 | guagua0407 | Bomb (IZhO17_bomb) | C++17 | 1103 ms | 43700 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.
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define all(x) x.begin(),x.end()
const int mxn=2505;
char c[mxn][mxn];
int pre[mxn][mxn];
bool used[mxn][mxn];
int mn[mxn];
int n,m;
bool check(int x,int y){
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
used[i][j]=false;
}
}
for(int j=1;j<=m;j++){
mn[j]=0;
}
int cur=0;
for(int i=y;i<=n;i++){
int prv=0;
for(int j=x;j<=m;j++){
int sum=pre[i][j]-pre[i][j-x]-pre[i-y][j]+pre[i-y][j-x];
if(sum!=x*y){
continue;
}
for(int k=max(prv+1,j-x+1);k<=j;k++){
for(int l=i;l>=max(mn[k]+1,i-y+1);l--){
used[l][k]=true;
cur++;
}
mn[k]=i;
}
prv=j;
}
}
return cur==pre[n][m];
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
auto st=clock();
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>c[i][j];
pre[i][j]=pre[i][j-1]+pre[i-1][j]-pre[i-1][j-1]+(c[i][j]=='1');
}
}
int ans=1;
set<int> S;
for(int len=m;len>=1;len--){
int r=(ans+len-1)/len;
while(r<=n and check(len,r)){
r++;
}
S.insert(r);
ans=max(ans,len*(r-1));
}
assert(S.size()<100);
cout<<ans<<'\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |