# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
505426 | pragmatist | Bomb (IZhO17_bomb) | C++17 | 3 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |