# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1017456 |
2024-07-09T08:09:09 Z |
Gray |
Bomb (IZhO17_bomb) |
C++17 |
|
251 ms |
80464 KB |
#include <cassert>
#include <iostream>
#include <vector>
#define ll int
#define ln "\n"
#define ff first
#define ss second
#define ld long double
const ll INF = 1e9;
const ll MOD = 1e9+7;
using namespace std;
void solve(){
ll n, m; cin >> n >> m;
vector<vector<ll>> a(n+1, vector<ll>(m+1)), left(n+1, vector<ll>(m+2)), right(n+1, vector<ll>(m+2));
for (ll i=1; i<=n; i++)
for (ll j=1; j<=m; j++){
char x; cin >> x;
a[i][j]=x-'0';
}
vector<ll> mxwid(n+1, INF);
for (ll i=1; i<=n; i++) {
for (ll j=1; j<=m; j++){
left[i][j] = a[i][j]?left[i][j-1]+1:0;
}
for (ll j=m; j>=1; j--){
right[i][j] = a[i][j]?right[i][j+1]+1:0;
if (a[i][j])mxwid[1]=min(mxwid[1], right[i][j]+left[i][j]-1);
}
}
ll mxh=INF;
for (ll j=1; j<=m; j++){
ll l=m, r=m, cc=0;
for (ll i=1; i<=n; i++){
if (a[i][j]){
l=min(l, left[i][j]);
r=min(r, right[i][j]);
cc++;
mxwid[cc]=min(mxwid[cc], l+r-1);
}else{
if (cc)mxh=min(mxh, cc);
cc=0;
l=m; r=m;
}
}
if (cc) mxh=min(mxh, cc);
}
for (ll j=m; j>=1; j--){
ll l=m, r=m, cc=0;
for (ll i=1; i<=n; i++){
if (a[i][j]){
l=min(l, left[i][j]);
r=min(r, right[i][j]);
cc++;
mxwid[cc]=min(mxwid[cc], l+r-1);
}else{
if (cc) mxh=min(mxh, cc);
cc=0;
l=m; r=m;
}
}
if (cc) mxh=min(mxh, cc);
}
ll ans=0;
for (ll i=1; i<=mxh; i++){
// cout << i << ":" << mxwid[i] << ln;
if (i>1) mxwid[i]=min(mxwid[i-1], mxwid[i]);
ans=max(ans, mxwid[i]*i);
}
cout << ans << ln;
}
void setIO(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int main(){
setIO();
ll t=1;
// cin >> t;
while (t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
860 KB |
Output is correct |
4 |
Correct |
1 ms |
860 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
604 KB |
Output is correct |
9 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
24 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
1380 KB |
Output is correct |
28 |
Correct |
2 ms |
1884 KB |
Output is correct |
29 |
Correct |
3 ms |
1884 KB |
Output is correct |
30 |
Incorrect |
4 ms |
2652 KB |
Output isn't correct |
31 |
Incorrect |
3 ms |
2396 KB |
Output isn't correct |
32 |
Incorrect |
5 ms |
2392 KB |
Output isn't correct |
33 |
Correct |
5 ms |
3100 KB |
Output is correct |
34 |
Correct |
2 ms |
1372 KB |
Output is correct |
35 |
Incorrect |
4 ms |
3028 KB |
Output isn't correct |
36 |
Correct |
5 ms |
2908 KB |
Output is correct |
37 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
38 |
Correct |
214 ms |
80040 KB |
Output is correct |
39 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
40 |
Correct |
23 ms |
10332 KB |
Output is correct |
41 |
Correct |
0 ms |
344 KB |
Output is correct |
42 |
Correct |
1 ms |
348 KB |
Output is correct |
43 |
Correct |
239 ms |
80148 KB |
Output is correct |
44 |
Correct |
4 ms |
2908 KB |
Output is correct |
45 |
Incorrect |
197 ms |
80172 KB |
Output isn't correct |
46 |
Correct |
188 ms |
80152 KB |
Output is correct |
47 |
Incorrect |
183 ms |
80148 KB |
Output isn't correct |
48 |
Correct |
175 ms |
80028 KB |
Output is correct |
49 |
Correct |
219 ms |
80212 KB |
Output is correct |
50 |
Correct |
177 ms |
80208 KB |
Output is correct |
51 |
Correct |
182 ms |
80084 KB |
Output is correct |
52 |
Correct |
199 ms |
80212 KB |
Output is correct |
53 |
Correct |
182 ms |
80212 KB |
Output is correct |
54 |
Correct |
162 ms |
80208 KB |
Output is correct |
55 |
Correct |
159 ms |
80024 KB |
Output is correct |
56 |
Correct |
219 ms |
80264 KB |
Output is correct |
57 |
Correct |
156 ms |
80208 KB |
Output is correct |
58 |
Correct |
160 ms |
80208 KB |
Output is correct |
59 |
Correct |
159 ms |
80208 KB |
Output is correct |
60 |
Correct |
181 ms |
80236 KB |
Output is correct |
61 |
Correct |
224 ms |
80212 KB |
Output is correct |
62 |
Correct |
251 ms |
80152 KB |
Output is correct |
63 |
Correct |
229 ms |
80212 KB |
Output is correct |
64 |
Correct |
169 ms |
80148 KB |
Output is correct |
65 |
Correct |
193 ms |
80212 KB |
Output is correct |
66 |
Correct |
193 ms |
80152 KB |
Output is correct |
67 |
Correct |
183 ms |
80156 KB |
Output is correct |
68 |
Correct |
188 ms |
80208 KB |
Output is correct |
69 |
Correct |
154 ms |
80208 KB |
Output is correct |
70 |
Incorrect |
95 ms |
51536 KB |
Output isn't correct |
71 |
Incorrect |
153 ms |
80208 KB |
Output isn't correct |
72 |
Correct |
159 ms |
80020 KB |
Output is correct |
73 |
Incorrect |
160 ms |
80208 KB |
Output isn't correct |
74 |
Incorrect |
176 ms |
80208 KB |
Output isn't correct |
75 |
Incorrect |
157 ms |
80264 KB |
Output isn't correct |
76 |
Correct |
155 ms |
80212 KB |
Output is correct |
77 |
Correct |
160 ms |
80208 KB |
Output is correct |
78 |
Correct |
155 ms |
80212 KB |
Output is correct |
79 |
Incorrect |
136 ms |
80212 KB |
Output isn't correct |
80 |
Incorrect |
145 ms |
80020 KB |
Output isn't correct |
81 |
Incorrect |
172 ms |
80148 KB |
Output isn't correct |
82 |
Correct |
159 ms |
80212 KB |
Output is correct |
83 |
Incorrect |
168 ms |
80028 KB |
Output isn't correct |
84 |
Incorrect |
133 ms |
80208 KB |
Output isn't correct |
85 |
Incorrect |
160 ms |
80024 KB |
Output isn't correct |
86 |
Incorrect |
217 ms |
80464 KB |
Output isn't correct |
87 |
Correct |
160 ms |
80028 KB |
Output is correct |
88 |
Incorrect |
158 ms |
80108 KB |
Output isn't correct |
89 |
Incorrect |
179 ms |
80036 KB |
Output isn't correct |
90 |
Incorrect |
126 ms |
51564 KB |
Output isn't correct |
91 |
Correct |
162 ms |
80208 KB |
Output is correct |
92 |
Correct |
176 ms |
80204 KB |
Output is correct |
93 |
Correct |
210 ms |
80208 KB |
Output is correct |
94 |
Incorrect |
179 ms |
80212 KB |
Output isn't correct |
95 |
Incorrect |
170 ms |
80212 KB |
Output isn't correct |
96 |
Incorrect |
168 ms |
80264 KB |
Output isn't correct |
97 |
Correct |
210 ms |
80212 KB |
Output is correct |
98 |
Correct |
155 ms |
80036 KB |
Output is correct |
99 |
Incorrect |
177 ms |
80216 KB |
Output isn't correct |
100 |
Incorrect |
206 ms |
80152 KB |
Output isn't correct |