# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
682566 |
2023-01-16T14:14:44 Z |
opPO |
Bomb (IZhO17_bomb) |
C++17 |
|
1000 ms |
73924 KB |
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define ld long double
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define vec vector
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
const ld eps = 1e-6;
const int mod = 998244353;
const int oo = 2e9;
const ll OO = 2e18;
const int N = 2501;
int n, m, a[N][N], pref[N][N], p[N][N];
int get(int x1, int y1, int x2, int y2)
{
return pref[x2][y2] - pref[x1 - 1][y2] - pref[x2][y1 - 1] + pref[x1 - 1][y1 - 1];
}
bool check(int h, int w)
{
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) p[i][j] = 0;
for (int x1 = 1; x1 <= n; x1++)
{
for (int y1 = 1; y1 <= m; y1++)
{
int x2 = x1 + h - 1, y2 = y1 + w - 1;
if (x2 > n || y2 > m) break;
if (get(x1, y1, x2, y2) == h * w)
{
p[x1][y1]++;
p[x1][y2 + 1]--;
p[x2 + 1][y1]--;
p[x2 + 1][y2 + 1]++;
}
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
p[i][j] += p[i - 1][j];
p[i][j] += p[i][j - 1];
p[i][j] -= p[i - 1][j - 1];
if (a[i][j] == 1 && p[i][j] == 0) return false;
}
}
return true;
}
void solve()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
char c;
cin >> c;
a[i][j] = c - '0';
pref[i][j] += a[i][j];
pref[i][j] += pref[i - 1][j];
pref[i][j] += pref[i][j - 1];
pref[i][j] -= pref[i - 1][j - 1];
}
}
int ans = 0;
int ptr = m;
for (int h = 1; h <= n; h++)
{
while (ptr >= 1 && !check(h, ptr)) ptr--;
ans = max(ans, h * ptr);
}
cout << ans;
}
int32_t main()
{
// freopen("bomb.in", "r", stdin);
// freopen("bomb.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
468 KB |
Output is correct |
3 |
Correct |
22 ms |
30444 KB |
Output is correct |
4 |
Correct |
21 ms |
30356 KB |
Output is correct |
5 |
Correct |
4 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
468 KB |
Output is correct |
9 |
Correct |
0 ms |
468 KB |
Output is correct |
10 |
Correct |
0 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
0 ms |
468 KB |
Output is correct |
13 |
Correct |
0 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
0 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
1 ms |
1108 KB |
Output is correct |
18 |
Correct |
2 ms |
1236 KB |
Output is correct |
19 |
Correct |
2 ms |
1492 KB |
Output is correct |
20 |
Correct |
2 ms |
1492 KB |
Output is correct |
21 |
Correct |
1 ms |
980 KB |
Output is correct |
22 |
Correct |
2 ms |
1236 KB |
Output is correct |
23 |
Correct |
2 ms |
1620 KB |
Output is correct |
24 |
Correct |
2 ms |
1320 KB |
Output is correct |
25 |
Correct |
4 ms |
1620 KB |
Output is correct |
26 |
Correct |
2 ms |
1620 KB |
Output is correct |
27 |
Correct |
23 ms |
4824 KB |
Output is correct |
28 |
Correct |
33 ms |
5156 KB |
Output is correct |
29 |
Correct |
78 ms |
6504 KB |
Output is correct |
30 |
Correct |
122 ms |
7720 KB |
Output is correct |
31 |
Correct |
84 ms |
6104 KB |
Output is correct |
32 |
Correct |
89 ms |
7040 KB |
Output is correct |
33 |
Correct |
143 ms |
8116 KB |
Output is correct |
34 |
Correct |
22 ms |
5588 KB |
Output is correct |
35 |
Correct |
79 ms |
8112 KB |
Output is correct |
36 |
Correct |
136 ms |
8120 KB |
Output is correct |
37 |
Correct |
0 ms |
468 KB |
Output is correct |
38 |
Execution timed out |
1098 ms |
73924 KB |
Time limit exceeded |
39 |
Correct |
1 ms |
468 KB |
Output is correct |
40 |
Execution timed out |
1080 ms |
19896 KB |
Time limit exceeded |
41 |
Correct |
0 ms |
468 KB |
Output is correct |
42 |
Correct |
3 ms |
1620 KB |
Output is correct |
43 |
Execution timed out |
1088 ms |
73728 KB |
Time limit exceeded |
44 |
Correct |
192 ms |
8120 KB |
Output is correct |
45 |
Execution timed out |
1094 ms |
73668 KB |
Time limit exceeded |
46 |
Execution timed out |
1093 ms |
73692 KB |
Time limit exceeded |
47 |
Execution timed out |
1101 ms |
73680 KB |
Time limit exceeded |
48 |
Execution timed out |
1099 ms |
73724 KB |
Time limit exceeded |
49 |
Execution timed out |
1087 ms |
73732 KB |
Time limit exceeded |
50 |
Execution timed out |
1096 ms |
73620 KB |
Time limit exceeded |
51 |
Execution timed out |
1096 ms |
73668 KB |
Time limit exceeded |
52 |
Execution timed out |
1100 ms |
73604 KB |
Time limit exceeded |
53 |
Execution timed out |
1095 ms |
73708 KB |
Time limit exceeded |
54 |
Execution timed out |
1089 ms |
73808 KB |
Time limit exceeded |
55 |
Execution timed out |
1058 ms |
73700 KB |
Time limit exceeded |
56 |
Execution timed out |
1088 ms |
73648 KB |
Time limit exceeded |
57 |
Execution timed out |
1100 ms |
73708 KB |
Time limit exceeded |
58 |
Execution timed out |
1094 ms |
73704 KB |
Time limit exceeded |
59 |
Execution timed out |
1090 ms |
73676 KB |
Time limit exceeded |
60 |
Execution timed out |
1089 ms |
73724 KB |
Time limit exceeded |
61 |
Execution timed out |
1099 ms |
73676 KB |
Time limit exceeded |
62 |
Execution timed out |
1092 ms |
73728 KB |
Time limit exceeded |
63 |
Execution timed out |
1084 ms |
73736 KB |
Time limit exceeded |
64 |
Execution timed out |
1084 ms |
73728 KB |
Time limit exceeded |
65 |
Execution timed out |
1085 ms |
73628 KB |
Time limit exceeded |
66 |
Execution timed out |
1095 ms |
73608 KB |
Time limit exceeded |
67 |
Execution timed out |
1096 ms |
73676 KB |
Time limit exceeded |
68 |
Execution timed out |
1090 ms |
73700 KB |
Time limit exceeded |
69 |
Execution timed out |
1087 ms |
73676 KB |
Time limit exceeded |
70 |
Execution timed out |
1091 ms |
59044 KB |
Time limit exceeded |
71 |
Execution timed out |
1096 ms |
73672 KB |
Time limit exceeded |
72 |
Execution timed out |
1097 ms |
73696 KB |
Time limit exceeded |
73 |
Execution timed out |
1089 ms |
73672 KB |
Time limit exceeded |
74 |
Execution timed out |
1077 ms |
73664 KB |
Time limit exceeded |
75 |
Execution timed out |
1091 ms |
73676 KB |
Time limit exceeded |
76 |
Execution timed out |
1096 ms |
73704 KB |
Time limit exceeded |
77 |
Execution timed out |
1093 ms |
73632 KB |
Time limit exceeded |
78 |
Execution timed out |
1098 ms |
73724 KB |
Time limit exceeded |
79 |
Execution timed out |
1098 ms |
73784 KB |
Time limit exceeded |
80 |
Execution timed out |
1100 ms |
73676 KB |
Time limit exceeded |
81 |
Execution timed out |
1104 ms |
73676 KB |
Time limit exceeded |
82 |
Execution timed out |
1104 ms |
73620 KB |
Time limit exceeded |
83 |
Execution timed out |
1093 ms |
73608 KB |
Time limit exceeded |
84 |
Execution timed out |
1099 ms |
73700 KB |
Time limit exceeded |
85 |
Execution timed out |
1100 ms |
73676 KB |
Time limit exceeded |
86 |
Execution timed out |
1091 ms |
73732 KB |
Time limit exceeded |
87 |
Execution timed out |
1097 ms |
73676 KB |
Time limit exceeded |
88 |
Execution timed out |
1073 ms |
73672 KB |
Time limit exceeded |
89 |
Execution timed out |
1094 ms |
73676 KB |
Time limit exceeded |
90 |
Execution timed out |
1101 ms |
59032 KB |
Time limit exceeded |
91 |
Execution timed out |
1080 ms |
73660 KB |
Time limit exceeded |
92 |
Execution timed out |
1063 ms |
73808 KB |
Time limit exceeded |
93 |
Execution timed out |
1101 ms |
73732 KB |
Time limit exceeded |
94 |
Execution timed out |
1103 ms |
73612 KB |
Time limit exceeded |
95 |
Execution timed out |
1104 ms |
73664 KB |
Time limit exceeded |
96 |
Execution timed out |
1099 ms |
73652 KB |
Time limit exceeded |
97 |
Execution timed out |
1082 ms |
73752 KB |
Time limit exceeded |
98 |
Execution timed out |
1075 ms |
73676 KB |
Time limit exceeded |
99 |
Execution timed out |
1073 ms |
73676 KB |
Time limit exceeded |
100 |
Execution timed out |
1100 ms |
73736 KB |
Time limit exceeded |