# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
705996 |
2023-03-05T18:17:24 Z |
KiriLL1ca |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
61188 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) {
int res = 0;
for (int j = 12; ~j; --j) {
res += pw(j);
if (res > m || bad(i, res, n, m)) res -= pw(j);
}
umax(ans, i * res);
}
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 |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
408 KB |
Output is correct |
3 |
Correct |
293 ms |
10580 KB |
Output is correct |
4 |
Correct |
319 ms |
10580 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 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
468 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 |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
15 ms |
668 KB |
Output is correct |
18 |
Correct |
13 ms |
724 KB |
Output is correct |
19 |
Correct |
34 ms |
852 KB |
Output is correct |
20 |
Correct |
35 ms |
852 KB |
Output is correct |
21 |
Correct |
12 ms |
676 KB |
Output is correct |
22 |
Correct |
22 ms |
724 KB |
Output is correct |
23 |
Correct |
47 ms |
852 KB |
Output is correct |
24 |
Correct |
25 ms |
724 KB |
Output is correct |
25 |
Correct |
49 ms |
852 KB |
Output is correct |
26 |
Correct |
53 ms |
892 KB |
Output is correct |
27 |
Execution timed out |
1086 ms |
2456 KB |
Time limit exceeded |
28 |
Execution timed out |
1077 ms |
2732 KB |
Time limit exceeded |
29 |
Execution timed out |
1077 ms |
3220 KB |
Time limit exceeded |
30 |
Execution timed out |
1070 ms |
4068 KB |
Time limit exceeded |
31 |
Execution timed out |
1071 ms |
3360 KB |
Time limit exceeded |
32 |
Execution timed out |
1062 ms |
3672 KB |
Time limit exceeded |
33 |
Execution timed out |
1074 ms |
4368 KB |
Time limit exceeded |
34 |
Execution timed out |
1075 ms |
2684 KB |
Time limit exceeded |
35 |
Execution timed out |
1068 ms |
4424 KB |
Time limit exceeded |
36 |
Execution timed out |
1062 ms |
4608 KB |
Time limit exceeded |
37 |
Correct |
1 ms |
468 KB |
Output is correct |
38 |
Execution timed out |
1022 ms |
60556 KB |
Time limit exceeded |
39 |
Correct |
1 ms |
468 KB |
Output is correct |
40 |
Execution timed out |
1069 ms |
11736 KB |
Time limit exceeded |
41 |
Correct |
1 ms |
468 KB |
Output is correct |
42 |
Correct |
50 ms |
900 KB |
Output is correct |
43 |
Execution timed out |
1056 ms |
60500 KB |
Time limit exceeded |
44 |
Execution timed out |
1065 ms |
4408 KB |
Time limit exceeded |
45 |
Execution timed out |
1047 ms |
60536 KB |
Time limit exceeded |
46 |
Execution timed out |
1020 ms |
60564 KB |
Time limit exceeded |
47 |
Execution timed out |
1022 ms |
60564 KB |
Time limit exceeded |
48 |
Execution timed out |
1102 ms |
60476 KB |
Time limit exceeded |
49 |
Execution timed out |
1040 ms |
60820 KB |
Time limit exceeded |
50 |
Execution timed out |
1086 ms |
60848 KB |
Time limit exceeded |
51 |
Execution timed out |
1020 ms |
60808 KB |
Time limit exceeded |
52 |
Execution timed out |
1026 ms |
61012 KB |
Time limit exceeded |
53 |
Execution timed out |
1100 ms |
61112 KB |
Time limit exceeded |
54 |
Execution timed out |
1092 ms |
61052 KB |
Time limit exceeded |
55 |
Execution timed out |
1086 ms |
61060 KB |
Time limit exceeded |
56 |
Execution timed out |
1026 ms |
60796 KB |
Time limit exceeded |
57 |
Execution timed out |
1025 ms |
61088 KB |
Time limit exceeded |
58 |
Execution timed out |
1026 ms |
60896 KB |
Time limit exceeded |
59 |
Execution timed out |
1031 ms |
61076 KB |
Time limit exceeded |
60 |
Execution timed out |
1100 ms |
61188 KB |
Time limit exceeded |
61 |
Execution timed out |
1012 ms |
60856 KB |
Time limit exceeded |
62 |
Execution timed out |
1025 ms |
60972 KB |
Time limit exceeded |
63 |
Execution timed out |
1008 ms |
60964 KB |
Time limit exceeded |
64 |
Execution timed out |
1022 ms |
61032 KB |
Time limit exceeded |
65 |
Execution timed out |
1010 ms |
61036 KB |
Time limit exceeded |
66 |
Execution timed out |
1014 ms |
60940 KB |
Time limit exceeded |
67 |
Execution timed out |
1094 ms |
60944 KB |
Time limit exceeded |
68 |
Execution timed out |
1006 ms |
60976 KB |
Time limit exceeded |
69 |
Execution timed out |
1008 ms |
61020 KB |
Time limit exceeded |
70 |
Execution timed out |
1031 ms |
44228 KB |
Time limit exceeded |
71 |
Execution timed out |
1031 ms |
60996 KB |
Time limit exceeded |
72 |
Execution timed out |
1022 ms |
60912 KB |
Time limit exceeded |
73 |
Execution timed out |
1043 ms |
61012 KB |
Time limit exceeded |
74 |
Execution timed out |
1026 ms |
59672 KB |
Time limit exceeded |
75 |
Execution timed out |
1052 ms |
57404 KB |
Time limit exceeded |
76 |
Execution timed out |
1068 ms |
56808 KB |
Time limit exceeded |
77 |
Execution timed out |
1068 ms |
57252 KB |
Time limit exceeded |
78 |
Execution timed out |
1056 ms |
56812 KB |
Time limit exceeded |
79 |
Execution timed out |
1081 ms |
56932 KB |
Time limit exceeded |
80 |
Execution timed out |
1082 ms |
56816 KB |
Time limit exceeded |
81 |
Execution timed out |
1076 ms |
56764 KB |
Time limit exceeded |
82 |
Execution timed out |
1074 ms |
56764 KB |
Time limit exceeded |
83 |
Execution timed out |
1033 ms |
56800 KB |
Time limit exceeded |
84 |
Execution timed out |
1078 ms |
56720 KB |
Time limit exceeded |
85 |
Execution timed out |
1081 ms |
56748 KB |
Time limit exceeded |
86 |
Execution timed out |
1076 ms |
56724 KB |
Time limit exceeded |
87 |
Execution timed out |
1065 ms |
56968 KB |
Time limit exceeded |
88 |
Execution timed out |
1083 ms |
57024 KB |
Time limit exceeded |
89 |
Execution timed out |
1077 ms |
56900 KB |
Time limit exceeded |
90 |
Execution timed out |
1083 ms |
40608 KB |
Time limit exceeded |
91 |
Execution timed out |
1081 ms |
56668 KB |
Time limit exceeded |
92 |
Execution timed out |
1079 ms |
57000 KB |
Time limit exceeded |
93 |
Execution timed out |
1090 ms |
56632 KB |
Time limit exceeded |
94 |
Execution timed out |
1079 ms |
56960 KB |
Time limit exceeded |
95 |
Execution timed out |
1087 ms |
56744 KB |
Time limit exceeded |
96 |
Execution timed out |
1084 ms |
56572 KB |
Time limit exceeded |
97 |
Execution timed out |
1063 ms |
56752 KB |
Time limit exceeded |
98 |
Execution timed out |
1083 ms |
56448 KB |
Time limit exceeded |
99 |
Execution timed out |
1083 ms |
56600 KB |
Time limit exceeded |
100 |
Execution timed out |
1095 ms |
56280 KB |
Time limit exceeded |