# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
93210 |
2019-01-07T09:31:37 Z |
Abelyan |
Bomb (IZhO17_bomb) |
C++17 |
|
195 ms |
58872 KB |
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define FOR(i, a) for (int i = 0; i < (a); i++)
#define F0R(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i,a) for (int i = (a)-1; i >= 0; i--)
#define F0Rd(i,a,b) for (int i = (b); i >= (a); i--)
#define trav(a, x) for (auto& a : x)
const int N = 2506;
char c[N][N];
int prdz[N][N], praj[N][N], ans1, ans2, pr[N];
void ad(int a, int b){
//cout << a << " " << b << endl;
if (a > ans2 || b > ans1)return;
pr[a] = min(pr[a], b);
}
int main(){
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 0; i<n; i++){
cin >> c[i];
pr[i] = INT_MAX;
}
pr[n] = INT_MAX;
int mn = INT_MAX;
for (int i = 0; i<n; i++){
int tv = 0;
for (int j = 0; j<m; j++){
if (c[i][j] == '1'){
if (j == 0)prdz[i][j] = 1;
else prdz[i][j] = prdz[i][j - 1] + 1;
tv++;
}
else if (tv != 0){
mn = min(mn, tv);
tv = 0;
}
}
for (int j = m - 1; j >= 0; j--){
if (c[i][j] == '1'){
praj[i][j] = praj[i][j + 1] + 1;
}
}
if (tv != 0)mn = min(mn, tv);
}
ans1 = mn;
mn = INT_MAX;
for (int j = 0; j<m; j++){
int tv = 0;
for (int i = 0; i<n; i++){
if (c[i][j] == '1'){
tv++;
}
else if (tv != 0){
mn = min(mn, tv);
tv = 0;
}
}
if (tv != 0)mn = min(mn, tv);
}
ans2 = mn;
//cout << ans1 << " " << ans2 << endl;
for (int j = 0; j < m; j++){
for (int i = 0; i < n; i++){
if (c[i][j] == '1' && (j == 0 || c[i][j - 1] == '0')){
int ans = INT_MAX,k=0;
while (i<n && c[i][j] == '1'){
k++;
ans = min(ans, praj[i][j]);
ad(k, ans);
i++;
}
i--;
}
else if (c[i][j]=='1' &&(j==m-1 || c[i][j+1]=='0')){
int ans = INT_MAX, k = 0;
while (i<n && c[i][j] == '1'){
k++;
ans = min(ans, prdz[i][j]);
ad(k, ans);
i++;
}
i--;
}
}
}
for (int j = 0; j<m; j++){
for (int i = n-1; i >= 0; i--){
if (c[i][j] == '1' && (j == 0 || c[i][j - 1] == '0')){
int ans = INT_MAX, k = 0;
while (i<n && c[i][j] == '1'){
k++;
ans = min(ans, praj[i][j]);
ad(k, ans);
i--;
}
i++;
}
else if (c[i][j] == '1' && (j == m - 1 || c[i][j + 1] == '0')){
int ans = INT_MAX, k = 0;
while (i<n && c[i][j] == '1'){
k++;
ans = min(ans, prdz[i][j]);
ad(k, ans);
i--;
}
i++;
}
}
}
int verj = 1;
for (int i = 1; i <= n; i++){
if (pr[i] == INT_MAX)continue;
verj = max(verj, i*pr[i]);
}
cout << verj << endl;
return 0;
}
/*
5 6
001000
111110
111110
111110
000100
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
25 ms |
26716 KB |
Output is correct |
4 |
Correct |
24 ms |
26532 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Correct |
2 ms |
504 KB |
Output is correct |
10 |
Correct |
2 ms |
576 KB |
Output is correct |
11 |
Correct |
2 ms |
504 KB |
Output is correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
508 KB |
Output is correct |
14 |
Correct |
2 ms |
552 KB |
Output is correct |
15 |
Correct |
2 ms |
504 KB |
Output is correct |
16 |
Correct |
2 ms |
632 KB |
Output is correct |
17 |
Incorrect |
2 ms |
1016 KB |
Output isn't correct |
18 |
Correct |
2 ms |
808 KB |
Output is correct |
19 |
Correct |
2 ms |
1016 KB |
Output is correct |
20 |
Correct |
2 ms |
1016 KB |
Output is correct |
21 |
Correct |
2 ms |
632 KB |
Output is correct |
22 |
Correct |
2 ms |
760 KB |
Output is correct |
23 |
Correct |
3 ms |
1016 KB |
Output is correct |
24 |
Correct |
2 ms |
1016 KB |
Output is correct |
25 |
Correct |
3 ms |
1400 KB |
Output is correct |
26 |
Incorrect |
3 ms |
1528 KB |
Output isn't correct |
27 |
Correct |
6 ms |
4216 KB |
Output is correct |
28 |
Correct |
3 ms |
1528 KB |
Output is correct |
29 |
Incorrect |
8 ms |
5368 KB |
Output isn't correct |
30 |
Correct |
7 ms |
4348 KB |
Output is correct |
31 |
Correct |
6 ms |
3164 KB |
Output is correct |
32 |
Correct |
6 ms |
4216 KB |
Output is correct |
33 |
Correct |
8 ms |
5496 KB |
Output is correct |
34 |
Correct |
4 ms |
1784 KB |
Output is correct |
35 |
Correct |
4 ms |
2168 KB |
Output is correct |
36 |
Incorrect |
9 ms |
6904 KB |
Output isn't correct |
37 |
Correct |
2 ms |
632 KB |
Output is correct |
38 |
Correct |
159 ms |
58872 KB |
Output is correct |
39 |
Correct |
2 ms |
632 KB |
Output is correct |
40 |
Incorrect |
25 ms |
16248 KB |
Output isn't correct |
41 |
Correct |
2 ms |
632 KB |
Output is correct |
42 |
Correct |
3 ms |
1404 KB |
Output is correct |
43 |
Correct |
195 ms |
54520 KB |
Output is correct |
44 |
Correct |
9 ms |
6264 KB |
Output is correct |
45 |
Correct |
169 ms |
55900 KB |
Output is correct |
46 |
Correct |
155 ms |
58444 KB |
Output is correct |
47 |
Correct |
161 ms |
55940 KB |
Output is correct |
48 |
Incorrect |
154 ms |
58204 KB |
Output isn't correct |
49 |
Correct |
173 ms |
58188 KB |
Output is correct |
50 |
Incorrect |
133 ms |
58336 KB |
Output isn't correct |
51 |
Incorrect |
139 ms |
58360 KB |
Output isn't correct |
52 |
Correct |
134 ms |
58104 KB |
Output is correct |
53 |
Correct |
152 ms |
57520 KB |
Output is correct |
54 |
Correct |
139 ms |
44764 KB |
Output is correct |
55 |
Correct |
115 ms |
43224 KB |
Output is correct |
56 |
Correct |
150 ms |
58232 KB |
Output is correct |
57 |
Correct |
127 ms |
38392 KB |
Output is correct |
58 |
Correct |
130 ms |
43384 KB |
Output is correct |
59 |
Correct |
126 ms |
40184 KB |
Output is correct |
60 |
Correct |
171 ms |
50032 KB |
Output is correct |
61 |
Correct |
186 ms |
57948 KB |
Output is correct |
62 |
Correct |
164 ms |
57848 KB |
Output is correct |
63 |
Correct |
157 ms |
57696 KB |
Output is correct |
64 |
Correct |
124 ms |
40568 KB |
Output is correct |
65 |
Correct |
156 ms |
56520 KB |
Output is correct |
66 |
Correct |
139 ms |
53928 KB |
Output is correct |
67 |
Incorrect |
138 ms |
57592 KB |
Output isn't correct |
68 |
Incorrect |
157 ms |
57720 KB |
Output isn't correct |
69 |
Correct |
125 ms |
37288 KB |
Output is correct |
70 |
Correct |
67 ms |
17508 KB |
Output is correct |
71 |
Correct |
112 ms |
29944 KB |
Output is correct |
72 |
Correct |
114 ms |
33616 KB |
Output is correct |
73 |
Correct |
115 ms |
34140 KB |
Output is correct |
74 |
Correct |
119 ms |
37772 KB |
Output is correct |
75 |
Correct |
119 ms |
39416 KB |
Output is correct |
76 |
Correct |
104 ms |
40864 KB |
Output is correct |
77 |
Correct |
103 ms |
41416 KB |
Output is correct |
78 |
Correct |
102 ms |
41592 KB |
Output is correct |
79 |
Correct |
69 ms |
13944 KB |
Output is correct |
80 |
Correct |
84 ms |
15364 KB |
Output is correct |
81 |
Correct |
80 ms |
15736 KB |
Output is correct |
82 |
Correct |
105 ms |
43640 KB |
Output is correct |
83 |
Correct |
108 ms |
43880 KB |
Output is correct |
84 |
Correct |
87 ms |
8940 KB |
Output is correct |
85 |
Correct |
127 ms |
42744 KB |
Output is correct |
86 |
Correct |
158 ms |
56116 KB |
Output is correct |
87 |
Correct |
113 ms |
41464 KB |
Output is correct |
88 |
Correct |
104 ms |
42448 KB |
Output is correct |
89 |
Correct |
122 ms |
50936 KB |
Output is correct |
90 |
Correct |
73 ms |
31224 KB |
Output is correct |
91 |
Correct |
130 ms |
46416 KB |
Output is correct |
92 |
Correct |
128 ms |
48076 KB |
Output is correct |
93 |
Correct |
135 ms |
55076 KB |
Output is correct |
94 |
Correct |
119 ms |
49760 KB |
Output is correct |
95 |
Correct |
104 ms |
43696 KB |
Output is correct |
96 |
Correct |
105 ms |
43228 KB |
Output is correct |
97 |
Correct |
152 ms |
55664 KB |
Output is correct |
98 |
Correct |
126 ms |
42776 KB |
Output is correct |
99 |
Correct |
137 ms |
49016 KB |
Output is correct |
100 |
Correct |
143 ms |
54300 KB |
Output is correct |