#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;
unsigned seed = chrono::system_clock::now().time_since_epoch().count();
mt19937 eng(seed);
ll random2(){
return (1ll << 31ll)*eng()+eng();
}
ll n,m,k,q,T;
const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod = 998244353;
const int MAXN = 2501;
bool grid[MAXN][MAXN] = {0};
bool covered[MAXN][MAXN] = {0};
bool can_place(int i, int j, int a, int b){
if(n-i < a || m-j < b)return 0;
rep(c1,0,a){
rep(c2,0,b){
if(!grid[i+c1][j+c2])return 0;
}
}
return 1;
}
bool can_cover(int i, int j, int a, int b){
rep(dx,0,a){
rep(dy,0,b){
int i2 = i - dx;
int j2 = j - dy;
if(i2 >= 0 && j2 >= 0 && can_place(i2,j2,a,b))return 1;
}
}
return 0;
}
bool solve(int a, int b){
rep(c1,0,n){
rep(c2,0,m){
if(grid[c1][c2] && (c1 == n-1 || !grid[c1+1][c2]) && !can_cover(c1,c2,a,b))return 0;
}
}
return 1;
}
int lft[MAXN][MAXN] = {0};
int up[MAXN][MAXN] = {0};
int mina = big;
int minb = big;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("fhc.txt","r",stdin);
// freopen("autput.txt","w",stdout);
ll a,b,c,d,e;
cin >> n >> m;
rep(c1,0,n){
string s;
cin >> s;
rep(c2,0,m){
grid[c1][c2] = (s[c2] == '1');
}
}
rep(c1,0,n){
rep(c2,0,m){
if(grid[c1][c2]){
if(c1 == 0){
up[c1][c2] = 1;
}
else{
up[c1][c2] = up[c1-1][c2]+1;
}
if(c1 == n-1 || !grid[c1+1][c2])mina = min(mina, up[c1][c2]);
if(c2 == 0){
lft[c1][c2] = 1;
}
else{
lft[c1][c2] = lft[c1][c2-1]+1;
}
if(c2 == m-1 || !grid[c1][c2+1])minb = min(minb, lft[c1][c2]);
}
}
}
ll ans = 0;
rep(a,1,mina+1){
rep(b,1,minb+1){
if(solve(a, b)){
ans = max(ans, (ll)a*b);
}
}
}
cout << ans << "\n";
return 0;
}
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:79:8: warning: unused variable 'a' [-Wunused-variable]
79 | ll a,b,c,d,e;
| ^
bomb.cpp:79:10: warning: unused variable 'b' [-Wunused-variable]
79 | ll a,b,c,d,e;
| ^
bomb.cpp:79:12: warning: unused variable 'c' [-Wunused-variable]
79 | ll a,b,c,d,e;
| ^
bomb.cpp:79:14: warning: unused variable 'd' [-Wunused-variable]
79 | ll a,b,c,d,e;
| ^
bomb.cpp:79:16: warning: unused variable 'e' [-Wunused-variable]
79 | ll a,b,c,d,e;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
468 KB |
Output is correct |
3 |
Correct |
10 ms |
26452 KB |
Output is correct |
4 |
Correct |
11 ms |
26444 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Incorrect |
0 ms |
468 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
468 KB |
Output isn't correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Incorrect |
0 ms |
468 KB |
Output isn't correct |
13 |
Correct |
0 ms |
468 KB |
Output is correct |
14 |
Correct |
0 ms |
468 KB |
Output is correct |
15 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
980 KB |
Output is correct |
18 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
19 |
Incorrect |
22 ms |
1040 KB |
Output isn't correct |
20 |
Incorrect |
27 ms |
980 KB |
Output isn't correct |
21 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
22 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
23 |
Incorrect |
266 ms |
980 KB |
Output isn't correct |
24 |
Incorrect |
26 ms |
1012 KB |
Output isn't correct |
25 |
Execution timed out |
1088 ms |
1236 KB |
Time limit exceeded |
26 |
Correct |
6 ms |
1364 KB |
Output is correct |
27 |
Correct |
3 ms |
4052 KB |
Output is correct |
28 |
Incorrect |
6 ms |
1364 KB |
Output isn't correct |
29 |
Execution timed out |
1094 ms |
5176 KB |
Time limit exceeded |
30 |
Execution timed out |
1085 ms |
4180 KB |
Time limit exceeded |
31 |
Execution timed out |
1085 ms |
3028 KB |
Time limit exceeded |
32 |
Execution timed out |
1088 ms |
4052 KB |
Time limit exceeded |
33 |
Execution timed out |
1063 ms |
5204 KB |
Time limit exceeded |
34 |
Incorrect |
12 ms |
1732 KB |
Output isn't correct |
35 |
Execution timed out |
1097 ms |
2004 KB |
Time limit exceeded |
36 |
Execution timed out |
1063 ms |
6612 KB |
Time limit exceeded |
37 |
Correct |
1 ms |
468 KB |
Output is correct |
38 |
Execution timed out |
1061 ms |
58952 KB |
Time limit exceeded |
39 |
Correct |
1 ms |
468 KB |
Output is correct |
40 |
Execution timed out |
1097 ms |
15512 KB |
Time limit exceeded |
41 |
Correct |
1 ms |
468 KB |
Output is correct |
42 |
Execution timed out |
1087 ms |
1364 KB |
Time limit exceeded |
43 |
Execution timed out |
1044 ms |
55144 KB |
Time limit exceeded |
44 |
Execution timed out |
1100 ms |
5972 KB |
Time limit exceeded |
45 |
Execution timed out |
1071 ms |
56396 KB |
Time limit exceeded |
46 |
Execution timed out |
1046 ms |
58900 KB |
Time limit exceeded |
47 |
Execution timed out |
1066 ms |
56524 KB |
Time limit exceeded |
48 |
Execution timed out |
1068 ms |
58956 KB |
Time limit exceeded |
49 |
Correct |
280 ms |
58952 KB |
Output is correct |
50 |
Execution timed out |
1052 ms |
59008 KB |
Time limit exceeded |
51 |
Execution timed out |
1054 ms |
58876 KB |
Time limit exceeded |
52 |
Execution timed out |
1075 ms |
58828 KB |
Time limit exceeded |
53 |
Execution timed out |
1048 ms |
58276 KB |
Time limit exceeded |
54 |
Execution timed out |
1059 ms |
45720 KB |
Time limit exceeded |
55 |
Execution timed out |
1045 ms |
43948 KB |
Time limit exceeded |
56 |
Execution timed out |
1039 ms |
58908 KB |
Time limit exceeded |
57 |
Execution timed out |
1039 ms |
39372 KB |
Time limit exceeded |
58 |
Execution timed out |
1006 ms |
44364 KB |
Time limit exceeded |
59 |
Execution timed out |
1031 ms |
41264 KB |
Time limit exceeded |
60 |
Execution timed out |
1046 ms |
51012 KB |
Time limit exceeded |
61 |
Execution timed out |
1099 ms |
59212 KB |
Time limit exceeded |
62 |
Execution timed out |
1035 ms |
59136 KB |
Time limit exceeded |
63 |
Execution timed out |
1054 ms |
59212 KB |
Time limit exceeded |
64 |
Execution timed out |
1048 ms |
42024 KB |
Time limit exceeded |
65 |
Execution timed out |
1051 ms |
58100 KB |
Time limit exceeded |
66 |
Execution timed out |
1045 ms |
55048 KB |
Time limit exceeded |
67 |
Execution timed out |
1043 ms |
59132 KB |
Time limit exceeded |
68 |
Execution timed out |
1048 ms |
59212 KB |
Time limit exceeded |
69 |
Execution timed out |
1049 ms |
38904 KB |
Time limit exceeded |
70 |
Execution timed out |
1093 ms |
17324 KB |
Time limit exceeded |
71 |
Execution timed out |
1041 ms |
31968 KB |
Time limit exceeded |
72 |
Execution timed out |
1037 ms |
37428 KB |
Time limit exceeded |
73 |
Execution timed out |
1035 ms |
37808 KB |
Time limit exceeded |
74 |
Execution timed out |
1040 ms |
39416 KB |
Time limit exceeded |
75 |
Execution timed out |
1033 ms |
40948 KB |
Time limit exceeded |
76 |
Execution timed out |
1052 ms |
42280 KB |
Time limit exceeded |
77 |
Execution timed out |
1053 ms |
42864 KB |
Time limit exceeded |
78 |
Execution timed out |
1040 ms |
43256 KB |
Time limit exceeded |
79 |
Execution timed out |
1040 ms |
15800 KB |
Time limit exceeded |
80 |
Execution timed out |
1035 ms |
17136 KB |
Time limit exceeded |
81 |
Execution timed out |
1032 ms |
17404 KB |
Time limit exceeded |
82 |
Execution timed out |
1042 ms |
45772 KB |
Time limit exceeded |
83 |
Execution timed out |
1058 ms |
45900 KB |
Time limit exceeded |
84 |
Execution timed out |
1032 ms |
11124 KB |
Time limit exceeded |
85 |
Execution timed out |
1010 ms |
44916 KB |
Time limit exceeded |
86 |
Execution timed out |
1048 ms |
58320 KB |
Time limit exceeded |
87 |
Execution timed out |
1018 ms |
44040 KB |
Time limit exceeded |
88 |
Execution timed out |
1093 ms |
44876 KB |
Time limit exceeded |
89 |
Execution timed out |
1040 ms |
53624 KB |
Time limit exceeded |
90 |
Execution timed out |
1030 ms |
32164 KB |
Time limit exceeded |
91 |
Execution timed out |
1006 ms |
48860 KB |
Time limit exceeded |
92 |
Execution timed out |
1047 ms |
50552 KB |
Time limit exceeded |
93 |
Execution timed out |
1040 ms |
57676 KB |
Time limit exceeded |
94 |
Execution timed out |
1028 ms |
52320 KB |
Time limit exceeded |
95 |
Execution timed out |
1030 ms |
46412 KB |
Time limit exceeded |
96 |
Execution timed out |
1035 ms |
46008 KB |
Time limit exceeded |
97 |
Execution timed out |
1089 ms |
58484 KB |
Time limit exceeded |
98 |
Execution timed out |
1039 ms |
45776 KB |
Time limit exceeded |
99 |
Execution timed out |
1095 ms |
52296 KB |
Time limit exceeded |
100 |
Execution timed out |
1038 ms |
57208 KB |
Time limit exceeded |