제출 #505426

#제출 시각아이디문제언어결과실행 시간메모리
505426pragmatistBomb (IZhO17_bomb)C++17
14 / 100
3 ms332 KiB
#include <bits/stdc++.h> #define pb push_back #define sz(v) (int)v.size() #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define x first #define y second #define int long long #define nl "\n" using namespace std; typedef long long ll; typedef pair<long long, long long> pll; typedef pair <ll, ll> pii; const int N = (int)1e6 + 7; const int M = (int)5e6 + 7; const ll MOD = (ll)1e9 + 7; const int inf = (int)1e9 + 7; const ll INF = (ll)3e18 + 7; pii dir[] = {{-1, -1}, {1, 1}, {-1, 1}, {1, -1}}; int n, m; char c[2501][2501]; bool used[2501][2501]; void solve() { cin >> n >> m; if(n > 20 || m > 20) return; for(int i = 1; i <= n; ++i) { for(int j = 1; j <= m; ++j) { cin >> c[i][j]; } } int ans = 0 ; for(int e = 1; e <= n; ++e) { for(int f = 1; f <= n; ++f) { bool ok = 1; for(int i = 1; i <= n; ++i) fill(used[i] + 1, used[i] + 1 + m, 0); for(int i = 1; i <= n; ++i) { for(int j = 1; j <= n; ++j) { if(i + e - 1 > n || j + f - 1 > m) continue; if(c[i][j] == '1') { bool cur = 1; for(int ii = i; ii <= i + e - 1 && cur; ++ii) { for(int jj = j; jj <= j + f - 1 && cur; ++jj) { cur &= (c[ii][jj] == '1'); } } if(cur) { for(int ii = i; ii <= i + e - 1 && cur; ++ii) { for(int jj = j; jj <= j + f - 1 && cur; ++jj) { used[ii][jj] = 1; } } } } } } for(int i = 1; i <= n && ok; ++i) { for(int j = 1; j <= n && ok; ++j) { if(c[i][j] == '1') ok &= (used[i][j] == 1); } } if(ok) { ans = max(ans, e * f); //cout << e << ' ' << f << nl; } } } cout << ans << nl; } signed main() { ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); int test = 1; //cin >> test; for(int i = 1; i <= test; ++i) { //cout << "Case " << i << ": "; solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...