/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#define ld long double
#define sz(v) (int)v.size()
#define ll long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define nl "\n"
using namespace std;
const int N = (int)25e2 + 7; // make sure this is right
const int M = (int)1e6 + 7;
const int B = 351;
const int inf = (int)2e9 + 7;
const ll INF = (ll)3e18 + 7;
const ll MOD = (ll)1e9 + 7; // make sure this is right
bool bit(int x, int i) {
return x >> i & 1;
}
int mult(int x, int y) {
return 1ll * x * y % MOD;
}
int sum(int x, int y) {
x += y;
if(x >= MOD) x -= MOD;
return x;
}
int n, m, p[N][N], e[N][N];
char a[N][N];
int get(int x1, int y1, int x2, int y2) {
return (p[x2][y2] - p[x1 - 1][y2] - p[x2][y1 - 1] + p[x1 - 1][y1 - 1]);
}
void solve() {
cin >> n >> m;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
cin >> a[i][j];
p[i][j] = p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1] + (a[i][j] == '1');
}
}
int ans = 0;
for(int h = 1; h <= n; ++h) {
for(int w = 1; w <= m; ++w) {
for(int i = 1; i <= n - h + 1; ++i) {
for(int j = 1; j <= m - w + 1; ++j) {
int ii = i + h - 1, jj = j + w - 1;
int x = get(i, j, ii, jj);
if(x == h * w) {
e[i][j]++;
e[i][jj + 1]--;
e[ii + 1][j]--;
e[ii + 1][jj + 1]++;
}
}
}
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
e[i][j] += e[i - 1][j];
e[i][j] += e[i][j - 1];
e[i][j] -= e[i - 1][j - 1];
}
}
bool ok = 1;
for(int i = 1; i <= n && ok; ++i) {
for(int j = 1; j <= m && ok; ++j) {
if(a[i][j] == '1') {
ok &= (e[i][j] > 0);
}
}
}
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
e[i][j] = 0;
}
}
if(ok) ans = max(ans, h * w);
}
}
cout << ans << "\n";
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int test = 1;
//cin >> test;
for(int i = 1; i <= test; ++i) {
//cout << "Case #" << i << ": ";
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
167 ms |
26540 KB |
Output is correct |
4 |
Correct |
160 ms |
26544 KB |
Output is correct |
5 |
Correct |
28 ms |
388 KB |
Output is correct |
6 |
Correct |
6 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
67 ms |
968 KB |
Output is correct |
18 |
Correct |
72 ms |
1108 KB |
Output is correct |
19 |
Correct |
201 ms |
1388 KB |
Output is correct |
20 |
Correct |
207 ms |
1364 KB |
Output is correct |
21 |
Correct |
75 ms |
928 KB |
Output is correct |
22 |
Correct |
179 ms |
1180 KB |
Output is correct |
23 |
Correct |
341 ms |
1456 KB |
Output is correct |
24 |
Correct |
119 ms |
1236 KB |
Output is correct |
25 |
Correct |
345 ms |
1456 KB |
Output is correct |
26 |
Correct |
387 ms |
1464 KB |
Output is correct |
27 |
Execution timed out |
1076 ms |
4052 KB |
Time limit exceeded |
28 |
Execution timed out |
1079 ms |
4284 KB |
Time limit exceeded |
29 |
Execution timed out |
1062 ms |
5460 KB |
Time limit exceeded |
30 |
Execution timed out |
1080 ms |
6500 KB |
Time limit exceeded |
31 |
Execution timed out |
1072 ms |
5124 KB |
Time limit exceeded |
32 |
Execution timed out |
1081 ms |
5972 KB |
Time limit exceeded |
33 |
Execution timed out |
1085 ms |
6740 KB |
Time limit exceeded |
34 |
Execution timed out |
1064 ms |
4820 KB |
Time limit exceeded |
35 |
Execution timed out |
1083 ms |
6740 KB |
Time limit exceeded |
36 |
Execution timed out |
1080 ms |
6740 KB |
Time limit exceeded |
37 |
Correct |
2 ms |
468 KB |
Output is correct |
38 |
Execution timed out |
1079 ms |
61540 KB |
Time limit exceeded |
39 |
Correct |
1 ms |
456 KB |
Output is correct |
40 |
Execution timed out |
1076 ms |
16272 KB |
Time limit exceeded |
41 |
Correct |
2 ms |
468 KB |
Output is correct |
42 |
Correct |
368 ms |
1460 KB |
Output is correct |
43 |
Execution timed out |
1084 ms |
61552 KB |
Time limit exceeded |
44 |
Execution timed out |
1067 ms |
6740 KB |
Time limit exceeded |
45 |
Execution timed out |
1076 ms |
61560 KB |
Time limit exceeded |
46 |
Execution timed out |
1072 ms |
61548 KB |
Time limit exceeded |
47 |
Execution timed out |
1058 ms |
61576 KB |
Time limit exceeded |
48 |
Execution timed out |
1046 ms |
61604 KB |
Time limit exceeded |
49 |
Execution timed out |
1081 ms |
61572 KB |
Time limit exceeded |
50 |
Execution timed out |
1052 ms |
61532 KB |
Time limit exceeded |
51 |
Execution timed out |
1078 ms |
61572 KB |
Time limit exceeded |
52 |
Execution timed out |
1048 ms |
61572 KB |
Time limit exceeded |
53 |
Execution timed out |
1032 ms |
61516 KB |
Time limit exceeded |
54 |
Execution timed out |
1078 ms |
61548 KB |
Time limit exceeded |
55 |
Execution timed out |
1050 ms |
61512 KB |
Time limit exceeded |
56 |
Execution timed out |
1081 ms |
61508 KB |
Time limit exceeded |
57 |
Execution timed out |
1085 ms |
61508 KB |
Time limit exceeded |
58 |
Execution timed out |
1084 ms |
61516 KB |
Time limit exceeded |
59 |
Execution timed out |
1084 ms |
61512 KB |
Time limit exceeded |
60 |
Execution timed out |
1071 ms |
61592 KB |
Time limit exceeded |
61 |
Execution timed out |
1038 ms |
61704 KB |
Time limit exceeded |
62 |
Execution timed out |
1071 ms |
61524 KB |
Time limit exceeded |
63 |
Execution timed out |
1059 ms |
61576 KB |
Time limit exceeded |
64 |
Execution timed out |
1070 ms |
61704 KB |
Time limit exceeded |
65 |
Execution timed out |
1076 ms |
61508 KB |
Time limit exceeded |
66 |
Execution timed out |
1060 ms |
61604 KB |
Time limit exceeded |
67 |
Execution timed out |
1088 ms |
61584 KB |
Time limit exceeded |
68 |
Execution timed out |
1080 ms |
61516 KB |
Time limit exceeded |
69 |
Execution timed out |
1052 ms |
61608 KB |
Time limit exceeded |
70 |
Execution timed out |
1083 ms |
48336 KB |
Time limit exceeded |
71 |
Execution timed out |
1075 ms |
61524 KB |
Time limit exceeded |
72 |
Execution timed out |
1074 ms |
61540 KB |
Time limit exceeded |
73 |
Execution timed out |
1070 ms |
61616 KB |
Time limit exceeded |
74 |
Execution timed out |
1038 ms |
61520 KB |
Time limit exceeded |
75 |
Execution timed out |
1046 ms |
61596 KB |
Time limit exceeded |
76 |
Execution timed out |
1068 ms |
61584 KB |
Time limit exceeded |
77 |
Execution timed out |
1047 ms |
61560 KB |
Time limit exceeded |
78 |
Execution timed out |
1075 ms |
61500 KB |
Time limit exceeded |
79 |
Execution timed out |
1076 ms |
61516 KB |
Time limit exceeded |
80 |
Execution timed out |
1069 ms |
61576 KB |
Time limit exceeded |
81 |
Execution timed out |
1069 ms |
61564 KB |
Time limit exceeded |
82 |
Execution timed out |
1088 ms |
61544 KB |
Time limit exceeded |
83 |
Execution timed out |
1081 ms |
61516 KB |
Time limit exceeded |
84 |
Execution timed out |
1074 ms |
61604 KB |
Time limit exceeded |
85 |
Execution timed out |
1072 ms |
61612 KB |
Time limit exceeded |
86 |
Execution timed out |
1082 ms |
61516 KB |
Time limit exceeded |
87 |
Execution timed out |
1078 ms |
61516 KB |
Time limit exceeded |
88 |
Execution timed out |
1069 ms |
61604 KB |
Time limit exceeded |
89 |
Execution timed out |
1077 ms |
61608 KB |
Time limit exceeded |
90 |
Execution timed out |
1086 ms |
48304 KB |
Time limit exceeded |
91 |
Execution timed out |
1060 ms |
61552 KB |
Time limit exceeded |
92 |
Execution timed out |
1074 ms |
61588 KB |
Time limit exceeded |
93 |
Execution timed out |
1077 ms |
61516 KB |
Time limit exceeded |
94 |
Execution timed out |
1036 ms |
61652 KB |
Time limit exceeded |
95 |
Execution timed out |
1084 ms |
61552 KB |
Time limit exceeded |
96 |
Execution timed out |
1087 ms |
61532 KB |
Time limit exceeded |
97 |
Execution timed out |
1061 ms |
61644 KB |
Time limit exceeded |
98 |
Execution timed out |
1059 ms |
61592 KB |
Time limit exceeded |
99 |
Execution timed out |
1056 ms |
61528 KB |
Time limit exceeded |
100 |
Execution timed out |
1064 ms |
61552 KB |
Time limit exceeded |