#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
3 ms |
332 KB |
Output is correct |
17 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
20 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
22 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
23 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
25 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
26 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
27 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
28 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
29 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
30 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
31 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
33 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
34 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
35 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
36 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
37 |
Correct |
1 ms |
332 KB |
Output is correct |
38 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
39 |
Correct |
2 ms |
332 KB |
Output is correct |
40 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
41 |
Correct |
3 ms |
332 KB |
Output is correct |
42 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
43 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
44 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
45 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
46 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
47 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
48 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
49 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
50 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
51 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
52 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
53 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
54 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
55 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
56 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
57 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
58 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
59 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
60 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
61 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
62 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
63 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
64 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
65 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
66 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
67 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
68 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
69 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
70 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
71 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
72 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
73 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
74 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
75 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
76 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
77 |
Incorrect |
1 ms |
248 KB |
Output isn't correct |
78 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
79 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
80 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
81 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
82 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
83 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
84 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
85 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
86 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
87 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
88 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
89 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
90 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
91 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
92 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
93 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
94 |
Incorrect |
1 ms |
308 KB |
Output isn't correct |
95 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
96 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
97 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
98 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
99 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
100 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |