# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
869705 |
2023-11-05T11:34:09 Z |
hentai_lover |
Bomb (IZhO17_bomb) |
C++14 |
|
1000 ms |
21960 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define fr(i, l, r) for(ll i = l; i <= r; ++ i)
#define rf(i, l, r) for(ll i = l; i >= r; -- i)
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using _set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef int ll;
typedef pair<ll, ll> pll;
const ll oo = ll(1e9) + 10;
ll p[3000][300];
ll get(ll x1, ll y1, ll x2, ll y2){
return p[x2][y2] - p[x2][y1 - 1] - p[x1 - 1][y2] + p[x1 - 1][y1 - 1];
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
ll n, m, ansx = 0, ansy = 0, ans = 0;
cin >> n >> m;
//if(n * m > 10000)return 0;
char a[n + 1][m + 1];
fr(i, 1, n)fr(j, 1, m){
cin >> a[i][j];
p[i][j] = p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1] + 1 - (a[i][j] - '0');
}
rf(r, n, 1){
rf(c, m, 1){
vector <pll> v;
fr(i, 1, n - r + 1){
fr(j, 1, m - c + 1){
//if(a[i][j] == '0')continue;
//cout << "i = " << i << " j = " << j << " get = " << get(i, j, i + r - 1, j + c - 1) << endl;
if(get(i, j, i + r - 1, j + c - 1) == 0)v.pb({i, j});
}
}
reverse(v.begin(), v.end());
//cout << "r = " << r << " c = " << c << endl;
//cout << "v: " << endl;
//for(auto i : v)cout << i.first << ' ' << i.second << endl;
bool usd[n + 1][m + 1];
fr(i, 1, n)fr(j, 1, m)usd[i][j] = 0;
for(auto x : v){
fr(i, 0, r - 1){
if(usd[x.first + i][x.second])break;
fr(j, 0, c - 1){
if(usd[x.first + i][x.second + j])break;
usd[x.first + i][x.second + j] = 1;
}
}
}
bool ok = 1;
fr(i, 1, n){
fr(j, 1, m){
if(a[i][j] == '1' && usd[i][j] == 0)ok = 0;
}
}
if(ok)ans = max(ans, r * c);
}
}
//cout << ansx << ' ' << ansy << endl;
ansx = oo, ansy = oo;
fr(i, 1, n){
fr(j, 1, m){
if(a[i][j] == '0')continue;
ll l = -1, r = -1, u = -1, d = -1;
fr(x, i, n){
if(a[x][j] == '0')break;
r = x;
}
if(r < 0)r = n;
rf(x, i, 1){
if(a[x][j] == '0')break;
l = x;
}
if(l < 0)l = 1;
fr(x, j, m){
if(a[i][x] == '0')break;
d = x;
}
if(d < 0)d = m;
rf(x, j, 1){
//cout << "u = " << u << " i = " << i << " x = " << x << " a[i][x] = " << a[i][x] << endl;
if(a[i][x] == '0')break;
u = x;
}
if(u < 0)u = 1;
ll a = r - l + 1;
ll b = d - u + 1;
//cout << "i = " << i << " j = " << j << "a = " << a << " b = " << b << " u = " << u << " d = " << d << endl;
ansx = min(ansx, a);
ansy = min(ansy, b);
}
}
//cout << ansx << ' ' << ansy << endl;
cout << ans;
if(ans > ansx * ansy)cout<<1/0;
cout << ansx * ansy << endl;
}
/*
3 3
011
111
111
*/
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:116:33: warning: division by zero [-Wdiv-by-zero]
116 | if(ans > ansx * ansy)cout<<1/0;
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Incorrect |
47 ms |
3424 KB |
Output isn't correct |
4 |
Incorrect |
42 ms |
3420 KB |
Output isn't correct |
5 |
Incorrect |
9 ms |
540 KB |
Output isn't correct |
6 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
11 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
16 |
Incorrect |
1 ms |
856 KB |
Output isn't correct |
17 |
Incorrect |
22 ms |
348 KB |
Output isn't correct |
18 |
Incorrect |
14 ms |
348 KB |
Output isn't correct |
19 |
Incorrect |
40 ms |
572 KB |
Output isn't correct |
20 |
Incorrect |
43 ms |
604 KB |
Output isn't correct |
21 |
Incorrect |
16 ms |
360 KB |
Output isn't correct |
22 |
Incorrect |
40 ms |
360 KB |
Output isn't correct |
23 |
Incorrect |
84 ms |
608 KB |
Output isn't correct |
24 |
Incorrect |
33 ms |
616 KB |
Output isn't correct |
25 |
Incorrect |
79 ms |
616 KB |
Output isn't correct |
26 |
Incorrect |
177 ms |
1060 KB |
Output isn't correct |
27 |
Execution timed out |
1067 ms |
3292 KB |
Time limit exceeded |
28 |
Execution timed out |
1051 ms |
2908 KB |
Time limit exceeded |
29 |
Execution timed out |
1055 ms |
3096 KB |
Time limit exceeded |
30 |
Execution timed out |
1024 ms |
3160 KB |
Time limit exceeded |
31 |
Execution timed out |
1032 ms |
2904 KB |
Time limit exceeded |
32 |
Execution timed out |
1062 ms |
2908 KB |
Time limit exceeded |
33 |
Execution timed out |
1058 ms |
3164 KB |
Time limit exceeded |
34 |
Execution timed out |
1027 ms |
2904 KB |
Time limit exceeded |
35 |
Execution timed out |
1080 ms |
3164 KB |
Time limit exceeded |
36 |
Execution timed out |
1058 ms |
3412 KB |
Time limit exceeded |
37 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
38 |
Execution timed out |
1018 ms |
21840 KB |
Time limit exceeded |
39 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
40 |
Execution timed out |
1049 ms |
4816 KB |
Time limit exceeded |
41 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
42 |
Incorrect |
114 ms |
604 KB |
Output isn't correct |
43 |
Execution timed out |
1062 ms |
21612 KB |
Time limit exceeded |
44 |
Execution timed out |
1063 ms |
3264 KB |
Time limit exceeded |
45 |
Execution timed out |
1043 ms |
21588 KB |
Time limit exceeded |
46 |
Execution timed out |
1022 ms |
21584 KB |
Time limit exceeded |
47 |
Execution timed out |
1030 ms |
21704 KB |
Time limit exceeded |
48 |
Execution timed out |
1068 ms |
21576 KB |
Time limit exceeded |
49 |
Execution timed out |
1028 ms |
21500 KB |
Time limit exceeded |
50 |
Execution timed out |
1006 ms |
21704 KB |
Time limit exceeded |
51 |
Execution timed out |
1052 ms |
21588 KB |
Time limit exceeded |
52 |
Execution timed out |
1034 ms |
21824 KB |
Time limit exceeded |
53 |
Execution timed out |
1058 ms |
21584 KB |
Time limit exceeded |
54 |
Execution timed out |
1044 ms |
21712 KB |
Time limit exceeded |
55 |
Execution timed out |
1025 ms |
21708 KB |
Time limit exceeded |
56 |
Execution timed out |
1020 ms |
21580 KB |
Time limit exceeded |
57 |
Execution timed out |
1030 ms |
21592 KB |
Time limit exceeded |
58 |
Execution timed out |
1029 ms |
21588 KB |
Time limit exceeded |
59 |
Execution timed out |
1051 ms |
21704 KB |
Time limit exceeded |
60 |
Execution timed out |
1101 ms |
21584 KB |
Time limit exceeded |
61 |
Execution timed out |
1016 ms |
21584 KB |
Time limit exceeded |
62 |
Execution timed out |
1036 ms |
21708 KB |
Time limit exceeded |
63 |
Execution timed out |
1008 ms |
21752 KB |
Time limit exceeded |
64 |
Execution timed out |
1028 ms |
21580 KB |
Time limit exceeded |
65 |
Execution timed out |
1010 ms |
21584 KB |
Time limit exceeded |
66 |
Execution timed out |
1018 ms |
21588 KB |
Time limit exceeded |
67 |
Execution timed out |
1018 ms |
21708 KB |
Time limit exceeded |
68 |
Execution timed out |
1018 ms |
21760 KB |
Time limit exceeded |
69 |
Execution timed out |
1034 ms |
21584 KB |
Time limit exceeded |
70 |
Execution timed out |
1041 ms |
14420 KB |
Time limit exceeded |
71 |
Execution timed out |
1037 ms |
21588 KB |
Time limit exceeded |
72 |
Execution timed out |
1030 ms |
21580 KB |
Time limit exceeded |
73 |
Execution timed out |
1043 ms |
21580 KB |
Time limit exceeded |
74 |
Execution timed out |
1044 ms |
21588 KB |
Time limit exceeded |
75 |
Execution timed out |
1018 ms |
21608 KB |
Time limit exceeded |
76 |
Execution timed out |
1027 ms |
21588 KB |
Time limit exceeded |
77 |
Execution timed out |
1065 ms |
21636 KB |
Time limit exceeded |
78 |
Execution timed out |
1032 ms |
21584 KB |
Time limit exceeded |
79 |
Execution timed out |
1051 ms |
21624 KB |
Time limit exceeded |
80 |
Execution timed out |
1022 ms |
21576 KB |
Time limit exceeded |
81 |
Execution timed out |
1022 ms |
21584 KB |
Time limit exceeded |
82 |
Execution timed out |
1032 ms |
21584 KB |
Time limit exceeded |
83 |
Execution timed out |
1027 ms |
21632 KB |
Time limit exceeded |
84 |
Execution timed out |
1069 ms |
21704 KB |
Time limit exceeded |
85 |
Execution timed out |
1032 ms |
21708 KB |
Time limit exceeded |
86 |
Execution timed out |
1104 ms |
21708 KB |
Time limit exceeded |
87 |
Execution timed out |
1067 ms |
21720 KB |
Time limit exceeded |
88 |
Execution timed out |
1082 ms |
21588 KB |
Time limit exceeded |
89 |
Execution timed out |
1056 ms |
21960 KB |
Time limit exceeded |
90 |
Execution timed out |
1047 ms |
14616 KB |
Time limit exceeded |
91 |
Execution timed out |
1066 ms |
21588 KB |
Time limit exceeded |
92 |
Execution timed out |
1058 ms |
21716 KB |
Time limit exceeded |
93 |
Execution timed out |
1064 ms |
21588 KB |
Time limit exceeded |
94 |
Execution timed out |
1033 ms |
21704 KB |
Time limit exceeded |
95 |
Execution timed out |
1010 ms |
21708 KB |
Time limit exceeded |
96 |
Execution timed out |
1090 ms |
21584 KB |
Time limit exceeded |
97 |
Execution timed out |
1022 ms |
21580 KB |
Time limit exceeded |
98 |
Execution timed out |
1041 ms |
21588 KB |
Time limit exceeded |
99 |
Execution timed out |
1052 ms |
21836 KB |
Time limit exceeded |
100 |
Execution timed out |
1054 ms |
21588 KB |
Time limit exceeded |