#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2500 + 7;
char a[N][N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
if (n == 1 || m == 1) {
vector <int> aa;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
char x;
cin >> x;
aa.push_back(x - '0');
}
}
int cnt = 1;
int res = 1e9;
for (int i = 1; i < max(n, m); i++) {
if (aa[i] != aa[i - 1]) {
if (aa[i - 1] == 1) {
res = min(res, cnt);
}
cnt = 0;
}
cnt++;
}
if (aa[max(n, m) - 1] == 1) {
res = min(res, cnt);
}
cout << res << '\n';
return 0;
}
if (max(n, m) > 100) {
//assert(0);
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
}
}
int ans = 0;
for (int x = 1; x <= n; x++) {
bool not_good = false;
for (int y = 1; y <= m; y++) {
char b[n + 7][m + 7];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
b[i][j] = a[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (i + x - 1 > n || j + y - 1 > m) {
continue;
}
bool bad = false;
for (int r = i; r <= i + x - 1; r++) {
for (int c = j; c <= j + y - 1; c++) {
if (b[r][c] == '0') {
bad = true;
}
if (bad) break;
}
if (bad) break;
}
if (bad) continue;
for (int r = i; r <= i + x - 1; r++) {
for (int c = j; c <= j + y - 1; c++) {
b[r][c] = '2';
}
}
}
}
bool good = true;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] == '0') {
continue;
}
if (a[i][j] == '1' && b[i][j] == '2') {
continue;
}
good = false;
if (!good) break;
}
if (!good) break;
}
if (good) {
ans = max(ans, x * y);
} else {
not_good = true;
break;
}
}
if (not_good) {
break;
}
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
420 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
17 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
18 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
19 |
Incorrect |
3 ms |
508 KB |
Output isn't correct |
20 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
21 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
22 |
Incorrect |
2 ms |
508 KB |
Output isn't correct |
23 |
Incorrect |
4 ms |
632 KB |
Output isn't correct |
24 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
25 |
Incorrect |
5 ms |
632 KB |
Output isn't correct |
26 |
Incorrect |
4 ms |
632 KB |
Output isn't correct |
27 |
Correct |
7 ms |
1272 KB |
Output is correct |
28 |
Incorrect |
8 ms |
1144 KB |
Output isn't correct |
29 |
Incorrect |
376 ms |
1628 KB |
Output isn't correct |
30 |
Incorrect |
378 ms |
1784 KB |
Output isn't correct |
31 |
Incorrect |
201 ms |
1540 KB |
Output isn't correct |
32 |
Incorrect |
70 ms |
1784 KB |
Output isn't correct |
33 |
Incorrect |
582 ms |
2040 KB |
Output isn't correct |
34 |
Incorrect |
9 ms |
1400 KB |
Output isn't correct |
35 |
Incorrect |
187 ms |
2044 KB |
Output isn't correct |
36 |
Incorrect |
119 ms |
1928 KB |
Output isn't correct |
37 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
38 |
Execution timed out |
1075 ms |
14148 KB |
Time limit exceeded |
39 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
40 |
Execution timed out |
1078 ms |
3960 KB |
Time limit exceeded |
41 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
42 |
Incorrect |
10 ms |
632 KB |
Output isn't correct |
43 |
Execution timed out |
1092 ms |
14200 KB |
Time limit exceeded |
44 |
Execution timed out |
1089 ms |
1784 KB |
Time limit exceeded |
45 |
Execution timed out |
1085 ms |
14192 KB |
Time limit exceeded |
46 |
Execution timed out |
1077 ms |
14204 KB |
Time limit exceeded |
47 |
Execution timed out |
1079 ms |
14200 KB |
Time limit exceeded |
48 |
Execution timed out |
1075 ms |
14116 KB |
Time limit exceeded |
49 |
Incorrect |
367 ms |
14252 KB |
Output isn't correct |
50 |
Execution timed out |
1064 ms |
14200 KB |
Time limit exceeded |
51 |
Execution timed out |
1083 ms |
14200 KB |
Time limit exceeded |
52 |
Execution timed out |
1072 ms |
14200 KB |
Time limit exceeded |
53 |
Execution timed out |
1076 ms |
14200 KB |
Time limit exceeded |
54 |
Execution timed out |
1072 ms |
14200 KB |
Time limit exceeded |
55 |
Execution timed out |
1046 ms |
14200 KB |
Time limit exceeded |
56 |
Execution timed out |
1077 ms |
14072 KB |
Time limit exceeded |
57 |
Execution timed out |
1069 ms |
14200 KB |
Time limit exceeded |
58 |
Execution timed out |
1051 ms |
14072 KB |
Time limit exceeded |
59 |
Execution timed out |
1074 ms |
14072 KB |
Time limit exceeded |
60 |
Execution timed out |
1070 ms |
13848 KB |
Time limit exceeded |
61 |
Execution timed out |
1074 ms |
13816 KB |
Time limit exceeded |
62 |
Execution timed out |
1086 ms |
13892 KB |
Time limit exceeded |
63 |
Execution timed out |
1072 ms |
13816 KB |
Time limit exceeded |
64 |
Execution timed out |
1080 ms |
13816 KB |
Time limit exceeded |
65 |
Execution timed out |
1077 ms |
13920 KB |
Time limit exceeded |
66 |
Execution timed out |
1068 ms |
14020 KB |
Time limit exceeded |
67 |
Execution timed out |
1077 ms |
13812 KB |
Time limit exceeded |
68 |
Execution timed out |
1083 ms |
13944 KB |
Time limit exceeded |
69 |
Execution timed out |
1075 ms |
13944 KB |
Time limit exceeded |
70 |
Execution timed out |
1076 ms |
10488 KB |
Time limit exceeded |
71 |
Execution timed out |
1078 ms |
13864 KB |
Time limit exceeded |
72 |
Execution timed out |
1082 ms |
13944 KB |
Time limit exceeded |
73 |
Execution timed out |
1080 ms |
13944 KB |
Time limit exceeded |
74 |
Execution timed out |
1082 ms |
13816 KB |
Time limit exceeded |
75 |
Execution timed out |
1085 ms |
13944 KB |
Time limit exceeded |
76 |
Execution timed out |
1082 ms |
14072 KB |
Time limit exceeded |
77 |
Execution timed out |
1071 ms |
14200 KB |
Time limit exceeded |
78 |
Execution timed out |
1071 ms |
14100 KB |
Time limit exceeded |
79 |
Incorrect |
760 ms |
14196 KB |
Output isn't correct |
80 |
Incorrect |
610 ms |
14200 KB |
Output isn't correct |
81 |
Execution timed out |
1076 ms |
14200 KB |
Time limit exceeded |
82 |
Execution timed out |
1081 ms |
14072 KB |
Time limit exceeded |
83 |
Execution timed out |
1084 ms |
14072 KB |
Time limit exceeded |
84 |
Execution timed out |
1078 ms |
13816 KB |
Time limit exceeded |
85 |
Execution timed out |
1070 ms |
13816 KB |
Time limit exceeded |
86 |
Execution timed out |
1068 ms |
14172 KB |
Time limit exceeded |
87 |
Execution timed out |
1074 ms |
14140 KB |
Time limit exceeded |
88 |
Execution timed out |
1052 ms |
14172 KB |
Time limit exceeded |
89 |
Execution timed out |
1033 ms |
14188 KB |
Time limit exceeded |
90 |
Execution timed out |
1041 ms |
10960 KB |
Time limit exceeded |
91 |
Execution timed out |
1040 ms |
14400 KB |
Time limit exceeded |
92 |
Execution timed out |
1066 ms |
14356 KB |
Time limit exceeded |
93 |
Execution timed out |
1062 ms |
14332 KB |
Time limit exceeded |
94 |
Execution timed out |
1069 ms |
14364 KB |
Time limit exceeded |
95 |
Execution timed out |
1061 ms |
14388 KB |
Time limit exceeded |
96 |
Execution timed out |
1070 ms |
14328 KB |
Time limit exceeded |
97 |
Execution timed out |
1062 ms |
14440 KB |
Time limit exceeded |
98 |
Execution timed out |
1071 ms |
14712 KB |
Time limit exceeded |
99 |
Execution timed out |
1076 ms |
14712 KB |
Time limit exceeded |
100 |
Execution timed out |
1066 ms |
14948 KB |
Time limit exceeded |