Submission #666364

#TimeUsernameProblemLanguageResultExecution timeMemory
666364Kaztaev_AlisherBomb (IZhO17_bomb)C++17
30 / 100
1086 ms42096 KiB
//#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[min(i1+x-1 , n)][min(j1+y-1 , m)] - dp[i1-1][min(j1+y-1 , m)] - dp[min(i1+x-1 , n)][j1-1] + dp[i1-1][j1-1];
					if(cnt == x*y) ok = 1;
				}	
			}
			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)

bomb.cpp: In function 'int main()':
bomb.cpp:17:48: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 | #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
      |                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
bomb.cpp:75:2: note: in expansion of macro 'file'
   75 |  file("bomb");
      |  ^~~~
bomb.cpp:17:77: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 | #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
      |                                                                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bomb.cpp:75:2: note: in expansion of macro 'file'
   75 |  file("bomb");
      |  ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...