# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
666363 | Kaztaev_Alisher | Bomb (IZhO17_bomb) | C++17 | 1085 ms | 45540 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 optomize ("Ofast")
//#pragma GCC optomize ("unroll-loops")
//#pragma GCC target ("avx,avx2,fma")
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define sz size
#define cl clear
#define ins insert
#define ers erase
#define pii pair < int , int >
#define pll pair< long long , long long >
#define all(x) x.begin() , x.end()
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define tostr(x) to_string(x)
#define tonum(s) atoi(s.c_str())
#define seon(x) setprecision(x)
#define bpop(x) __builtin_popcount(x)
#define deb(x) cerr << #x << " = " << x << endl;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
const double PI = 3.14159265;
const ll N = 2e3+5;
const ll mod = 1e9+7;
const ll inf = 1e9;
const ll INF = 1e18;
using namespace std;
char c[N][N];
int dp[N][N];
int n , m;
bool check(int x, int y){
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(c[i][j] == 0) continue;
bool ok = 0;
for(int i1 = max(1, i-x+1); i1 <= i; i1++){
for(int j1 = max(1, j-y+1); j1 <= j; j1++){
int cnt = dp[i1+x-1][j1+y-1] - dp[i1-1][j1+y-1] - dp[i1+x-1][j1-1] + dp[i1-1][j1-1];
if(cnt == x*y) ok = 1;
if(x == 3 && y == 1 && i == 1 && j == 3){
// cout << cnt <<" | " << i1+x-1 <<" " << j1+y-1 <<" | " << i1-1 << ' ' << j1+x-1 <<" | " << i1+y-1<<" " << j1-1<<" | " << i1-1 <<" " << j1-1 <<"\n";
}
}
}
if(ok == 0) return 0;
}
}
return 1;
}
void solve(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> c[i][j];
c[i][j] -= '0';
dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + c[i][j];
}
}
ll ans = 0;
for(ll i = 1; i <= n; i++){
for(ll j = 1; j <= m; j++){
if(check(i,j)){
ans = max(ans , i*j);
}
}
}
cout << ans <<"\n";
}
signed main(){
file("bomb");
ios;
solve();
return 0;
}
/*
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |