# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
705995 |
2023-03-05T18:16:21 Z |
KiriLL1ca |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
62660 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fr first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define endl '\n'
#define sz(x) (int)((x).size())
#define vec vector
#define pw(x) (1ll << x)
using namespace std;
using namespace __gnu_pbds;
template <typename T> inline bool umin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool umax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int N = 2505;
string a[N];
int p[N][N];
inline int get (int x, int y, int xx, int yy) {
int res = p[xx][yy];
if (x) res -= p[x - 1][yy];
if (y) res -= p[xx][y - 1];
if (x && y) res += p[x - 1][y - 1];
return res;
}
inline bool bad (int s, int t, int n, int m) {
vector <vector <int>> f (n + 1, vector <int> (m + 1));
for (int i = 0; i + s - 1 < n; ++i) {
for (int j = 0; j + t - 1 < m; ++j) {
if (get(i, j, i + s - 1, j + t - 1) == s * t) {
++f[i][j];
--f[i + s][j];
--f[i][j + t];
++f[i + s][j + t];
}
}
}
for (int i = 0; i <= n; ++i) {
for (int j = 0; j <= m; ++j) {
if (i) f[i][j] += f[i - 1][j];
if (j) f[i][j] += f[i][j - 1];
if (i && j) f[i][j] -= f[i - 1][j - 1];
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if (a[i][j] == '1' && !f[i][j]) return 1;
}
}
return 0;
}
inline void solve () {
int n, m; cin >> n >> m;
for (int i = 0; i < n; ++i) cin >> a[i];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if (i) p[i][j] += p[i - 1][j];
if (j) p[i][j] += p[i][j - 1];
if (i && j) p[i][j] -= p[i - 1][j - 1];
p[i][j] += (a[i][j] - '0');
}
}
int ans = 0;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (!bad(i, j, n, m)) umax(ans, i * j);
}
}
cout << ans << endl;
}
signed main () {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif// LOCAL
int t = 1; //cin >> t;
while (t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
297 ms |
10580 KB |
Output is correct |
4 |
Correct |
300 ms |
10580 KB |
Output is correct |
5 |
Correct |
55 ms |
340 KB |
Output is correct |
6 |
Correct |
10 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
404 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
488 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
135 ms |
696 KB |
Output is correct |
18 |
Correct |
115 ms |
776 KB |
Output is correct |
19 |
Correct |
336 ms |
852 KB |
Output is correct |
20 |
Correct |
376 ms |
852 KB |
Output is correct |
21 |
Correct |
141 ms |
656 KB |
Output is correct |
22 |
Correct |
316 ms |
724 KB |
Output is correct |
23 |
Correct |
631 ms |
892 KB |
Output is correct |
24 |
Correct |
226 ms |
784 KB |
Output is correct |
25 |
Correct |
633 ms |
896 KB |
Output is correct |
26 |
Correct |
649 ms |
896 KB |
Output is correct |
27 |
Execution timed out |
1069 ms |
2452 KB |
Time limit exceeded |
28 |
Execution timed out |
1084 ms |
2660 KB |
Time limit exceeded |
29 |
Execution timed out |
1076 ms |
3320 KB |
Time limit exceeded |
30 |
Execution timed out |
1036 ms |
4152 KB |
Time limit exceeded |
31 |
Execution timed out |
1070 ms |
3292 KB |
Time limit exceeded |
32 |
Execution timed out |
1083 ms |
3592 KB |
Time limit exceeded |
33 |
Execution timed out |
1069 ms |
4396 KB |
Time limit exceeded |
34 |
Execution timed out |
1076 ms |
2756 KB |
Time limit exceeded |
35 |
Execution timed out |
1081 ms |
4468 KB |
Time limit exceeded |
36 |
Execution timed out |
1084 ms |
4396 KB |
Time limit exceeded |
37 |
Correct |
2 ms |
468 KB |
Output is correct |
38 |
Execution timed out |
1048 ms |
62324 KB |
Time limit exceeded |
39 |
Correct |
2 ms |
468 KB |
Output is correct |
40 |
Execution timed out |
1082 ms |
11792 KB |
Time limit exceeded |
41 |
Correct |
2 ms |
468 KB |
Output is correct |
42 |
Correct |
651 ms |
972 KB |
Output is correct |
43 |
Execution timed out |
1043 ms |
62416 KB |
Time limit exceeded |
44 |
Execution timed out |
1083 ms |
4432 KB |
Time limit exceeded |
45 |
Execution timed out |
1038 ms |
62572 KB |
Time limit exceeded |
46 |
Execution timed out |
1037 ms |
62360 KB |
Time limit exceeded |
47 |
Execution timed out |
1038 ms |
62236 KB |
Time limit exceeded |
48 |
Execution timed out |
1050 ms |
62220 KB |
Time limit exceeded |
49 |
Execution timed out |
1043 ms |
62364 KB |
Time limit exceeded |
50 |
Execution timed out |
1028 ms |
62416 KB |
Time limit exceeded |
51 |
Execution timed out |
1038 ms |
62276 KB |
Time limit exceeded |
52 |
Execution timed out |
1056 ms |
62228 KB |
Time limit exceeded |
53 |
Execution timed out |
1029 ms |
62436 KB |
Time limit exceeded |
54 |
Execution timed out |
1039 ms |
62416 KB |
Time limit exceeded |
55 |
Execution timed out |
1044 ms |
62232 KB |
Time limit exceeded |
56 |
Execution timed out |
1022 ms |
62412 KB |
Time limit exceeded |
57 |
Execution timed out |
1042 ms |
62468 KB |
Time limit exceeded |
58 |
Execution timed out |
1051 ms |
62336 KB |
Time limit exceeded |
59 |
Execution timed out |
1044 ms |
62660 KB |
Time limit exceeded |
60 |
Execution timed out |
1040 ms |
62532 KB |
Time limit exceeded |
61 |
Execution timed out |
1044 ms |
62524 KB |
Time limit exceeded |
62 |
Execution timed out |
1045 ms |
62404 KB |
Time limit exceeded |
63 |
Execution timed out |
1036 ms |
62400 KB |
Time limit exceeded |
64 |
Execution timed out |
1018 ms |
62616 KB |
Time limit exceeded |
65 |
Execution timed out |
1036 ms |
62488 KB |
Time limit exceeded |
66 |
Execution timed out |
1050 ms |
62276 KB |
Time limit exceeded |
67 |
Execution timed out |
1040 ms |
62420 KB |
Time limit exceeded |
68 |
Execution timed out |
1041 ms |
62476 KB |
Time limit exceeded |
69 |
Execution timed out |
1042 ms |
62324 KB |
Time limit exceeded |
70 |
Execution timed out |
1059 ms |
44068 KB |
Time limit exceeded |
71 |
Execution timed out |
1048 ms |
62452 KB |
Time limit exceeded |
72 |
Execution timed out |
1037 ms |
62316 KB |
Time limit exceeded |
73 |
Execution timed out |
1028 ms |
62368 KB |
Time limit exceeded |
74 |
Execution timed out |
1038 ms |
62316 KB |
Time limit exceeded |
75 |
Execution timed out |
1010 ms |
62400 KB |
Time limit exceeded |
76 |
Execution timed out |
1041 ms |
62460 KB |
Time limit exceeded |
77 |
Execution timed out |
1034 ms |
62300 KB |
Time limit exceeded |
78 |
Execution timed out |
1029 ms |
62232 KB |
Time limit exceeded |
79 |
Execution timed out |
1032 ms |
62364 KB |
Time limit exceeded |
80 |
Execution timed out |
1082 ms |
62308 KB |
Time limit exceeded |
81 |
Execution timed out |
1028 ms |
62308 KB |
Time limit exceeded |
82 |
Execution timed out |
1046 ms |
62244 KB |
Time limit exceeded |
83 |
Execution timed out |
1042 ms |
62348 KB |
Time limit exceeded |
84 |
Execution timed out |
1041 ms |
62300 KB |
Time limit exceeded |
85 |
Execution timed out |
1053 ms |
62228 KB |
Time limit exceeded |
86 |
Execution timed out |
1014 ms |
62284 KB |
Time limit exceeded |
87 |
Execution timed out |
1032 ms |
62320 KB |
Time limit exceeded |
88 |
Execution timed out |
1042 ms |
62276 KB |
Time limit exceeded |
89 |
Execution timed out |
1051 ms |
62320 KB |
Time limit exceeded |
90 |
Execution timed out |
1036 ms |
44008 KB |
Time limit exceeded |
91 |
Execution timed out |
1033 ms |
62304 KB |
Time limit exceeded |
92 |
Execution timed out |
1029 ms |
62228 KB |
Time limit exceeded |
93 |
Execution timed out |
1028 ms |
62308 KB |
Time limit exceeded |
94 |
Execution timed out |
1037 ms |
62300 KB |
Time limit exceeded |
95 |
Execution timed out |
1051 ms |
62392 KB |
Time limit exceeded |
96 |
Execution timed out |
1014 ms |
62448 KB |
Time limit exceeded |
97 |
Execution timed out |
1016 ms |
62360 KB |
Time limit exceeded |
98 |
Execution timed out |
1035 ms |
62488 KB |
Time limit exceeded |
99 |
Execution timed out |
1044 ms |
62364 KB |
Time limit exceeded |
100 |
Execution timed out |
1045 ms |
62392 KB |
Time limit exceeded |