# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
386465 | vanic | Bomb (IZhO17_bomb) | C++14 | 1078 ms | 1388 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 <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <array>
#include <bitset>
#include <cassert>
using namespace std;
const int maxn=2505;
bitset < maxn > a[maxn];
bitset < maxn > b[maxn];
int n, m;
bool provjeri(int x, int y){
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
b[i][j]=a[i][j];
}
}
bool ne;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
if(a[i][j]){
ne=0;
for(int k=i; k<i+x; k++){
for(int l=j; l<j+y; l++){
if(k>=n || l>=m || !a[k][l]){
ne=1;
break;
}
if(ne){
break;
}
}
}
if(!ne){
for(int k=i; k<i+x; k++){
for(int l=j; l<j+y; l++){
b[k][l]=0;
}
}
}
}
}
}
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
if(b[i][j]){
return 0;
}
}
}
return 1;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
string s;
for(int i=0; i<n; i++){
cin >> s;
for(int j=0; j<m; j++){
if(s[j]=='1'){
a[i][j]=1;
}
}
}
int br=0;
int mr=1e9, mc=1e9;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
if(a[i][j]){
br++;
}
else if(br){
mr=min(mr, br);
br=0;
}
}
if(br){
mr=min(mr, br);
br=0;
}
}
for(int j=0; j<m; j++){
for(int i=0; i<n; i++){
if(a[i][j]){
br++;
}
else if(br){
mc=min(mc, br);
br=0;
}
}
if(br){
mc=min(mc, br);
br=0;
}
}
assert(mr!=1e9);
if(n>100 || m>100){
cout << mr*mc << '\n';
return 0;
}
int maksi=0;
for(int i=mc; i>0; i--){
for(int j=mr; j>0; j--){
if(provjeri(i, j)){
maksi=max(maksi, i*j);
}
}
}
cout << maksi << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |