#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MX = 2505;
char inp[MX][MX];
int board[MX][MX];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin >> n >> m;
for(int i =1 ; i<= n ; i++)
{
for(int j =1 ; j <= m;j++)
{
cin >> inp[i][j];
board[i][j] = inp[i][j] - '0';
board[i][j] += board[i][j-1];
}
}
for(int i =1 ; i<= n ; i++)
{
for(int j =1 ; j <= m;j++)
{
board[i][j] += board[i-1][j];
}
}
// for(int i =1 ; i<= n ; i++)
// {
// for(int j =1 ; j <= m;j++)
// {
// cout << board[i][j] <<" ";
// }
// cout << "\n";
// }
int ans = 0;
for(int h = 1; h <= n; h++)
{
for(int w = 1; w <= m ; w++)
{
vector<vector<bool>> ok(MX, vector<bool>(MX,0));
bool y = 1;
for(int i =1 ; i<= n ; i++)
{
for(int j =1 ; j <= m;j++)
{
if(inp[i][j] != '1'){
continue;
}
int sum = board[i+h-1][j+w-1];
sum -= board[i-1][j+w-1];
sum -= board[i+h-1][j-1];
sum += board[i-1][j-1];
if(sum != h*w)
{
if(ok[i][j]){
continue;
}
y = 0;
break;
}else{
for(int oi = i ; oi <= i+h-1; oi++){
for(int oj = j; oj <= j+w-1;oj++){
ok[oi][oj] = 1;
}
}
}
}
if(!y){
break;
}
}
if(y){
ans = max(ans, h*w);
}
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1256 KB |
Output is correct |
2 |
Correct |
6 ms |
1504 KB |
Output is correct |
3 |
Correct |
780 ms |
17416 KB |
Output is correct |
4 |
Correct |
669 ms |
17412 KB |
Output is correct |
5 |
Correct |
636 ms |
1268 KB |
Output is correct |
6 |
Correct |
267 ms |
1260 KB |
Output is correct |
7 |
Correct |
7 ms |
1280 KB |
Output is correct |
8 |
Correct |
109 ms |
1384 KB |
Output is correct |
9 |
Correct |
109 ms |
1952 KB |
Output is correct |
10 |
Correct |
50 ms |
1340 KB |
Output is correct |
11 |
Correct |
100 ms |
1376 KB |
Output is correct |
12 |
Correct |
60 ms |
1352 KB |
Output is correct |
13 |
Correct |
46 ms |
1344 KB |
Output is correct |
14 |
Correct |
67 ms |
1352 KB |
Output is correct |
15 |
Correct |
90 ms |
1360 KB |
Output is correct |
16 |
Correct |
104 ms |
1380 KB |
Output is correct |
17 |
Execution timed out |
1081 ms |
2440 KB |
Time limit exceeded |
18 |
Execution timed out |
1049 ms |
1864 KB |
Time limit exceeded |
19 |
Execution timed out |
1056 ms |
2584 KB |
Time limit exceeded |
20 |
Execution timed out |
1037 ms |
2564 KB |
Time limit exceeded |
21 |
Execution timed out |
1041 ms |
1724 KB |
Time limit exceeded |
22 |
Execution timed out |
1032 ms |
2548 KB |
Time limit exceeded |
23 |
Execution timed out |
1062 ms |
2692 KB |
Time limit exceeded |
24 |
Execution timed out |
1054 ms |
1828 KB |
Time limit exceeded |
25 |
Execution timed out |
1058 ms |
2576 KB |
Time limit exceeded |
26 |
Execution timed out |
1062 ms |
1976 KB |
Time limit exceeded |
27 |
Execution timed out |
1041 ms |
3608 KB |
Time limit exceeded |
28 |
Execution timed out |
1058 ms |
3652 KB |
Time limit exceeded |
29 |
Execution timed out |
1072 ms |
4292 KB |
Time limit exceeded |
30 |
Execution timed out |
1026 ms |
4784 KB |
Time limit exceeded |
31 |
Execution timed out |
1050 ms |
4108 KB |
Time limit exceeded |
32 |
Execution timed out |
1061 ms |
4576 KB |
Time limit exceeded |
33 |
Execution timed out |
1052 ms |
5016 KB |
Time limit exceeded |
34 |
Execution timed out |
1042 ms |
4584 KB |
Time limit exceeded |
35 |
Execution timed out |
1070 ms |
5092 KB |
Time limit exceeded |
36 |
Execution timed out |
1061 ms |
5036 KB |
Time limit exceeded |
37 |
Correct |
103 ms |
1380 KB |
Output is correct |
38 |
Execution timed out |
1068 ms |
31948 KB |
Time limit exceeded |
39 |
Correct |
103 ms |
1376 KB |
Output is correct |
40 |
Execution timed out |
1094 ms |
9908 KB |
Time limit exceeded |
41 |
Correct |
107 ms |
1964 KB |
Output is correct |
42 |
Execution timed out |
1049 ms |
1984 KB |
Time limit exceeded |
43 |
Execution timed out |
1050 ms |
31908 KB |
Time limit exceeded |
44 |
Execution timed out |
1068 ms |
5104 KB |
Time limit exceeded |
45 |
Execution timed out |
1039 ms |
31900 KB |
Time limit exceeded |
46 |
Execution timed out |
1070 ms |
32520 KB |
Time limit exceeded |
47 |
Execution timed out |
1051 ms |
31868 KB |
Time limit exceeded |
48 |
Execution timed out |
1046 ms |
31900 KB |
Time limit exceeded |
49 |
Execution timed out |
1068 ms |
31980 KB |
Time limit exceeded |
50 |
Execution timed out |
1042 ms |
31948 KB |
Time limit exceeded |
51 |
Execution timed out |
1046 ms |
31908 KB |
Time limit exceeded |
52 |
Execution timed out |
1044 ms |
31920 KB |
Time limit exceeded |
53 |
Execution timed out |
1044 ms |
31868 KB |
Time limit exceeded |
54 |
Execution timed out |
1053 ms |
31880 KB |
Time limit exceeded |
55 |
Execution timed out |
1041 ms |
31900 KB |
Time limit exceeded |
56 |
Execution timed out |
1045 ms |
31928 KB |
Time limit exceeded |
57 |
Execution timed out |
1050 ms |
31960 KB |
Time limit exceeded |
58 |
Execution timed out |
1042 ms |
31908 KB |
Time limit exceeded |
59 |
Execution timed out |
1068 ms |
31868 KB |
Time limit exceeded |
60 |
Execution timed out |
1079 ms |
31876 KB |
Time limit exceeded |
61 |
Execution timed out |
1079 ms |
31876 KB |
Time limit exceeded |
62 |
Execution timed out |
1061 ms |
31912 KB |
Time limit exceeded |
63 |
Execution timed out |
1055 ms |
31880 KB |
Time limit exceeded |
64 |
Execution timed out |
1050 ms |
32016 KB |
Time limit exceeded |
65 |
Execution timed out |
1054 ms |
31920 KB |
Time limit exceeded |
66 |
Execution timed out |
1043 ms |
31976 KB |
Time limit exceeded |
67 |
Execution timed out |
1057 ms |
31996 KB |
Time limit exceeded |
68 |
Execution timed out |
1067 ms |
31904 KB |
Time limit exceeded |
69 |
Execution timed out |
1052 ms |
31948 KB |
Time limit exceeded |
70 |
Execution timed out |
1056 ms |
25824 KB |
Time limit exceeded |
71 |
Execution timed out |
1057 ms |
31908 KB |
Time limit exceeded |
72 |
Execution timed out |
1061 ms |
31976 KB |
Time limit exceeded |
73 |
Execution timed out |
1063 ms |
31900 KB |
Time limit exceeded |
74 |
Execution timed out |
1056 ms |
31900 KB |
Time limit exceeded |
75 |
Execution timed out |
1053 ms |
31964 KB |
Time limit exceeded |
76 |
Execution timed out |
1047 ms |
31904 KB |
Time limit exceeded |
77 |
Execution timed out |
1048 ms |
31904 KB |
Time limit exceeded |
78 |
Execution timed out |
1038 ms |
31904 KB |
Time limit exceeded |
79 |
Execution timed out |
1056 ms |
32592 KB |
Time limit exceeded |
80 |
Execution timed out |
1041 ms |
32008 KB |
Time limit exceeded |
81 |
Execution timed out |
1034 ms |
31872 KB |
Time limit exceeded |
82 |
Execution timed out |
1044 ms |
31864 KB |
Time limit exceeded |
83 |
Execution timed out |
1063 ms |
31900 KB |
Time limit exceeded |
84 |
Execution timed out |
1050 ms |
31940 KB |
Time limit exceeded |
85 |
Execution timed out |
1085 ms |
31872 KB |
Time limit exceeded |
86 |
Execution timed out |
1078 ms |
31864 KB |
Time limit exceeded |
87 |
Execution timed out |
1088 ms |
31868 KB |
Time limit exceeded |
88 |
Execution timed out |
1044 ms |
31948 KB |
Time limit exceeded |
89 |
Execution timed out |
1049 ms |
31864 KB |
Time limit exceeded |
90 |
Execution timed out |
1054 ms |
25772 KB |
Time limit exceeded |
91 |
Execution timed out |
1063 ms |
31900 KB |
Time limit exceeded |
92 |
Execution timed out |
1055 ms |
31872 KB |
Time limit exceeded |
93 |
Execution timed out |
1051 ms |
31952 KB |
Time limit exceeded |
94 |
Execution timed out |
1053 ms |
31980 KB |
Time limit exceeded |
95 |
Execution timed out |
1069 ms |
31968 KB |
Time limit exceeded |
96 |
Execution timed out |
1064 ms |
31952 KB |
Time limit exceeded |
97 |
Execution timed out |
1053 ms |
31872 KB |
Time limit exceeded |
98 |
Execution timed out |
1067 ms |
31960 KB |
Time limit exceeded |
99 |
Execution timed out |
1080 ms |
31892 KB |
Time limit exceeded |
100 |
Execution timed out |
1086 ms |
31952 KB |
Time limit exceeded |