# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
334582 |
2020-12-09T13:08:16 Z |
amunduzbaev |
Bomb (IZhO17_bomb) |
C++14 |
|
178 ms |
75884 KB |
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ld long double
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define prc(n) fixed << setprecision(n)
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1);
const int inf = 1e9+7;
const int N = 2505;
int a[N][N], mnc, mnr, d[N][N], u[N][N], ans[N];
void solve(){
mnr = inf, mnc = inf;
int n, m;
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';
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j])u[i][j] = u[i-1][j] + 1;
}
}
for(int i=n;i>0;i--){
for(int j=1;j<=m;j++){
if(a[i][j]){
d[i][j] = d[i+1][j]+1;
if(a[i+1][j] == 0) mnc = min(mnc, u[i][j]);
}
}
}
for(int i=1;i<=m;i++) ans[i] = mnc;
for(int i=1;i<=n;i++){
int aa = inf, b = inf, c = 0;
for(int j=1;j<=m;j++){
if(a[i][j] == 0){
if(c!=0) mnc = min(c, mnc);
aa = b = inf, c = 0;
}else{
aa = min(aa, d[i][j]);
b = min(b, u[i][j]);
c++;
ans[c] = min(ans[c], b + aa -1);
}
}
aa = inf, b = inf, c = 0;
for(int j = m; j>0; j--){
if(a[i][j] == 0){
if(c!=0) mnr = min(mnr, c);
aa = b = inf, c = 0;
}else{
aa = min(d[i][j], aa);
b = min(u[i][j], b);
c++;
ans[c] = min(ans[c], b + aa -1);
}
}
if(c > 0) mnr = min(mnr, c);
}
int mx = 0;
for(int i=1;i<=mnr;i++){
mx = max(ans[i] * i, mx);
}
cout<<mx<<"\n";
return;
}
int main(){
fastios
int t = 1;
//cin>>t;
while(t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
620 KB |
Output is correct |
3 |
Correct |
15 ms |
30444 KB |
Output is correct |
4 |
Correct |
17 ms |
30572 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
620 KB |
Output is correct |
12 |
Correct |
1 ms |
492 KB |
Output is correct |
13 |
Correct |
1 ms |
492 KB |
Output is correct |
14 |
Correct |
1 ms |
492 KB |
Output is correct |
15 |
Correct |
1 ms |
492 KB |
Output is correct |
16 |
Correct |
1 ms |
620 KB |
Output is correct |
17 |
Correct |
1 ms |
1132 KB |
Output is correct |
18 |
Correct |
1 ms |
1004 KB |
Output is correct |
19 |
Correct |
1 ms |
1260 KB |
Output is correct |
20 |
Correct |
1 ms |
1260 KB |
Output is correct |
21 |
Correct |
1 ms |
748 KB |
Output is correct |
22 |
Correct |
1 ms |
1004 KB |
Output is correct |
23 |
Correct |
1 ms |
1260 KB |
Output is correct |
24 |
Correct |
1 ms |
1132 KB |
Output is correct |
25 |
Correct |
1 ms |
1516 KB |
Output is correct |
26 |
Correct |
1 ms |
1644 KB |
Output is correct |
27 |
Correct |
5 ms |
4844 KB |
Output is correct |
28 |
Correct |
4 ms |
2412 KB |
Output is correct |
29 |
Correct |
7 ms |
6380 KB |
Output is correct |
30 |
Correct |
7 ms |
5740 KB |
Output is correct |
31 |
Correct |
6 ms |
4204 KB |
Output is correct |
32 |
Correct |
7 ms |
5356 KB |
Output is correct |
33 |
Correct |
9 ms |
6764 KB |
Output is correct |
34 |
Correct |
4 ms |
2668 KB |
Output is correct |
35 |
Correct |
6 ms |
3564 KB |
Output is correct |
36 |
Correct |
10 ms |
8300 KB |
Output is correct |
37 |
Correct |
1 ms |
620 KB |
Output is correct |
38 |
Correct |
177 ms |
75756 KB |
Output is correct |
39 |
Correct |
1 ms |
620 KB |
Output is correct |
40 |
Correct |
29 ms |
20076 KB |
Output is correct |
41 |
Correct |
1 ms |
620 KB |
Output is correct |
42 |
Correct |
2 ms |
1644 KB |
Output is correct |
43 |
Correct |
172 ms |
70764 KB |
Output is correct |
44 |
Correct |
10 ms |
7676 KB |
Output is correct |
45 |
Correct |
170 ms |
71660 KB |
Output is correct |
46 |
Correct |
176 ms |
75884 KB |
Output is correct |
47 |
Correct |
174 ms |
71788 KB |
Output is correct |
48 |
Correct |
175 ms |
75628 KB |
Output is correct |
49 |
Correct |
175 ms |
75756 KB |
Output is correct |
50 |
Correct |
174 ms |
75756 KB |
Output is correct |
51 |
Correct |
169 ms |
74220 KB |
Output is correct |
52 |
Correct |
167 ms |
74732 KB |
Output is correct |
53 |
Correct |
167 ms |
73580 KB |
Output is correct |
54 |
Correct |
162 ms |
61036 KB |
Output is correct |
55 |
Correct |
157 ms |
59116 KB |
Output is correct |
56 |
Correct |
178 ms |
75756 KB |
Output is correct |
57 |
Correct |
156 ms |
54252 KB |
Output is correct |
58 |
Correct |
157 ms |
59196 KB |
Output is correct |
59 |
Correct |
156 ms |
56172 KB |
Output is correct |
60 |
Correct |
165 ms |
66156 KB |
Output is correct |
61 |
Correct |
176 ms |
75756 KB |
Output is correct |
62 |
Correct |
173 ms |
75756 KB |
Output is correct |
63 |
Correct |
172 ms |
75756 KB |
Output is correct |
64 |
Correct |
156 ms |
57068 KB |
Output is correct |
65 |
Correct |
166 ms |
73088 KB |
Output is correct |
66 |
Correct |
166 ms |
70124 KB |
Output is correct |
67 |
Correct |
170 ms |
75884 KB |
Output is correct |
68 |
Correct |
170 ms |
75756 KB |
Output is correct |
69 |
Correct |
153 ms |
53740 KB |
Output is correct |
70 |
Correct |
96 ms |
30188 KB |
Output is correct |
71 |
Correct |
151 ms |
46828 KB |
Output is correct |
72 |
Correct |
153 ms |
52332 KB |
Output is correct |
73 |
Correct |
152 ms |
52716 KB |
Output is correct |
74 |
Correct |
155 ms |
54252 KB |
Output is correct |
75 |
Correct |
155 ms |
55916 KB |
Output is correct |
76 |
Correct |
160 ms |
57324 KB |
Output is correct |
77 |
Correct |
162 ms |
57836 KB |
Output is correct |
78 |
Correct |
159 ms |
57964 KB |
Output is correct |
79 |
Correct |
138 ms |
30492 KB |
Output is correct |
80 |
Correct |
140 ms |
31852 KB |
Output is correct |
81 |
Correct |
140 ms |
32108 KB |
Output is correct |
82 |
Correct |
168 ms |
60700 KB |
Output is correct |
83 |
Correct |
159 ms |
60652 KB |
Output is correct |
84 |
Correct |
148 ms |
25708 KB |
Output is correct |
85 |
Correct |
158 ms |
59500 KB |
Output is correct |
86 |
Correct |
174 ms |
74604 KB |
Output is correct |
87 |
Correct |
158 ms |
58732 KB |
Output is correct |
88 |
Correct |
158 ms |
59372 KB |
Output is correct |
89 |
Correct |
163 ms |
68076 KB |
Output is correct |
90 |
Correct |
105 ms |
44652 KB |
Output is correct |
91 |
Correct |
164 ms |
63340 KB |
Output is correct |
92 |
Correct |
162 ms |
65004 KB |
Output is correct |
93 |
Correct |
172 ms |
73708 KB |
Output is correct |
94 |
Correct |
166 ms |
66796 KB |
Output is correct |
95 |
Correct |
157 ms |
60652 KB |
Output is correct |
96 |
Correct |
159 ms |
60524 KB |
Output is correct |
97 |
Correct |
175 ms |
74476 KB |
Output is correct |
98 |
Correct |
163 ms |
60140 KB |
Output is correct |
99 |
Correct |
166 ms |
66412 KB |
Output is correct |
100 |
Correct |
172 ms |
73324 KB |
Output is correct |