#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <array>
#include <bitset>
#include <cassert>
using namespace std;
const int maxn=2505;
bitset < maxn > a[maxn];
bitset < maxn > b[maxn];
int n, m;
bool provjeri(int x, int y){
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
b[i][j]=a[i][j];
}
}
bool ne;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
if(a[i][j]){
ne=0;
for(int k=i; k<i+x; k++){
for(int l=j; l<j+y; l++){
if(k>=n || l>=m || !a[k][l]){
ne=1;
break;
}
if(ne){
break;
}
}
}
if(!ne){
for(int k=i; k<i+x; k++){
for(int l=j; l<j+y; l++){
b[k][l]=0;
}
}
}
}
}
}
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
if(b[i][j]){
return 0;
}
}
}
return 1;
}
vector < array < int, 3 > > svi;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
string s;
for(int i=0; i<n; i++){
cin >> s;
for(int j=0; j<m; j++){
if(s[j]=='1'){
a[i][j]=1;
}
}
}
int br=0;
int mr=1e9, mc=1e9;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
if(a[i][j]){
br++;
}
else if(br){
mr=min(mr, br);
br=0;
}
}
if(br){
mr=min(mr, br);
br=0;
}
}
for(int j=0; j<m; j++){
for(int i=0; i<n; i++){
if(a[i][j]){
br++;
}
else if(br){
mc=min(mc, br);
br=0;
}
}
if(br){
mc=min(mc, br);
br=0;
}
}
assert(mr!=1e9);
for(int i=mc; i>0; i--){
for(int j=mr; j>0; j--){
svi.push_back({i*j, i, j});
}
}
sort(svi.begin(), svi.end());
for(int i=svi.size()-1; i>-1; i--){
if(provjeri(svi[i][1], svi[i][2])){
cout << svi[i][0] << '\n';
return 0;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
3 ms |
1900 KB |
Output is correct |
4 |
Correct |
3 ms |
1900 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
32 ms |
364 KB |
Output is correct |
20 |
Correct |
35 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
2 ms |
364 KB |
Output is correct |
23 |
Correct |
125 ms |
364 KB |
Output is correct |
24 |
Correct |
37 ms |
364 KB |
Output is correct |
25 |
Correct |
819 ms |
508 KB |
Output is correct |
26 |
Correct |
5 ms |
364 KB |
Output is correct |
27 |
Correct |
3 ms |
492 KB |
Output is correct |
28 |
Correct |
13 ms |
492 KB |
Output is correct |
29 |
Execution timed out |
1089 ms |
748 KB |
Time limit exceeded |
30 |
Execution timed out |
1094 ms |
816 KB |
Time limit exceeded |
31 |
Execution timed out |
1095 ms |
748 KB |
Time limit exceeded |
32 |
Execution timed out |
1080 ms |
748 KB |
Time limit exceeded |
33 |
Execution timed out |
1090 ms |
1004 KB |
Time limit exceeded |
34 |
Correct |
12 ms |
492 KB |
Output is correct |
35 |
Execution timed out |
1089 ms |
620 KB |
Time limit exceeded |
36 |
Correct |
851 ms |
748 KB |
Output is correct |
37 |
Correct |
1 ms |
364 KB |
Output is correct |
38 |
Execution timed out |
1089 ms |
99824 KB |
Time limit exceeded |
39 |
Correct |
1 ms |
364 KB |
Output is correct |
40 |
Execution timed out |
1085 ms |
3812 KB |
Time limit exceeded |
41 |
Correct |
1 ms |
364 KB |
Output is correct |
42 |
Execution timed out |
1099 ms |
492 KB |
Time limit exceeded |
43 |
Execution timed out |
1096 ms |
4956 KB |
Time limit exceeded |
44 |
Execution timed out |
1081 ms |
1388 KB |
Time limit exceeded |
45 |
Execution timed out |
1086 ms |
25932 KB |
Time limit exceeded |
46 |
Correct |
385 ms |
1988 KB |
Output is correct |
47 |
Execution timed out |
1076 ms |
25940 KB |
Time limit exceeded |
48 |
Execution timed out |
1093 ms |
2028 KB |
Time limit exceeded |
49 |
Correct |
604 ms |
2028 KB |
Output is correct |
50 |
Execution timed out |
1092 ms |
2092 KB |
Time limit exceeded |
51 |
Execution timed out |
1088 ms |
2156 KB |
Time limit exceeded |
52 |
Execution timed out |
1086 ms |
2156 KB |
Time limit exceeded |
53 |
Execution timed out |
1087 ms |
2028 KB |
Time limit exceeded |
54 |
Execution timed out |
1097 ms |
2028 KB |
Time limit exceeded |
55 |
Execution timed out |
1098 ms |
2028 KB |
Time limit exceeded |
56 |
Execution timed out |
1088 ms |
3692 KB |
Time limit exceeded |
57 |
Execution timed out |
1093 ms |
1900 KB |
Time limit exceeded |
58 |
Execution timed out |
1088 ms |
2092 KB |
Time limit exceeded |
59 |
Execution timed out |
1085 ms |
2028 KB |
Time limit exceeded |
60 |
Execution timed out |
1098 ms |
1900 KB |
Time limit exceeded |
61 |
Execution timed out |
1091 ms |
1900 KB |
Time limit exceeded |
62 |
Execution timed out |
1091 ms |
3424 KB |
Time limit exceeded |
63 |
Execution timed out |
1093 ms |
25932 KB |
Time limit exceeded |
64 |
Execution timed out |
1098 ms |
2788 KB |
Time limit exceeded |
65 |
Execution timed out |
1096 ms |
2028 KB |
Time limit exceeded |
66 |
Execution timed out |
1097 ms |
2092 KB |
Time limit exceeded |
67 |
Execution timed out |
1100 ms |
2220 KB |
Time limit exceeded |
68 |
Execution timed out |
1097 ms |
2280 KB |
Time limit exceeded |
69 |
Execution timed out |
1064 ms |
1892 KB |
Time limit exceeded |
70 |
Execution timed out |
1097 ms |
3808 KB |
Time limit exceeded |
71 |
Execution timed out |
1098 ms |
7132 KB |
Time limit exceeded |
72 |
Execution timed out |
1093 ms |
13400 KB |
Time limit exceeded |
73 |
Execution timed out |
1086 ms |
13400 KB |
Time limit exceeded |
74 |
Execution timed out |
1097 ms |
13400 KB |
Time limit exceeded |
75 |
Execution timed out |
1096 ms |
13528 KB |
Time limit exceeded |
76 |
Execution timed out |
1100 ms |
13528 KB |
Time limit exceeded |
77 |
Execution timed out |
1092 ms |
13488 KB |
Time limit exceeded |
78 |
Execution timed out |
1101 ms |
13528 KB |
Time limit exceeded |
79 |
Execution timed out |
1099 ms |
1508 KB |
Time limit exceeded |
80 |
Execution timed out |
1100 ms |
1516 KB |
Time limit exceeded |
81 |
Execution timed out |
1088 ms |
2292 KB |
Time limit exceeded |
82 |
Execution timed out |
1095 ms |
13528 KB |
Time limit exceeded |
83 |
Execution timed out |
1099 ms |
13528 KB |
Time limit exceeded |
84 |
Execution timed out |
1089 ms |
1260 KB |
Time limit exceeded |
85 |
Execution timed out |
1065 ms |
7388 KB |
Time limit exceeded |
86 |
Execution timed out |
1046 ms |
2028 KB |
Time limit exceeded |
87 |
Execution timed out |
1095 ms |
4700 KB |
Time limit exceeded |
88 |
Execution timed out |
1091 ms |
13528 KB |
Time limit exceeded |
89 |
Execution timed out |
1095 ms |
3168 KB |
Time limit exceeded |
90 |
Execution timed out |
1093 ms |
4192 KB |
Time limit exceeded |
91 |
Execution timed out |
1091 ms |
4320 KB |
Time limit exceeded |
92 |
Execution timed out |
1090 ms |
3424 KB |
Time limit exceeded |
93 |
Execution timed out |
1098 ms |
2028 KB |
Time limit exceeded |
94 |
Execution timed out |
1097 ms |
3168 KB |
Time limit exceeded |
95 |
Execution timed out |
1095 ms |
13528 KB |
Time limit exceeded |
96 |
Execution timed out |
1098 ms |
13528 KB |
Time limit exceeded |
97 |
Execution timed out |
1094 ms |
2028 KB |
Time limit exceeded |
98 |
Execution timed out |
1089 ms |
13528 KB |
Time limit exceeded |
99 |
Execution timed out |
1095 ms |
3168 KB |
Time limit exceeded |
100 |
Execution timed out |
1088 ms |
2028 KB |
Time limit exceeded |