# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
93233 |
2019-01-07T10:24:02 Z |
Abelyan |
Bomb (IZhO17_bomb) |
C++17 |
|
206 ms |
55672 KB |
#include <iostream>
#include <algorithm>
#include <climits>
#include <cassert>
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)return;
if (b > ans1)b = ans1;
pr[a] = min(pr[a], b);
}
int main(){
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
//assert(n <= 20 && m <= 20);
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>=0 && 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>=0 && 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 |
21 ms |
26488 KB |
Output is correct |
4 |
Correct |
24 ms |
26488 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 |
504 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 |
504 KB |
Output is correct |
14 |
Correct |
2 ms |
504 KB |
Output is correct |
15 |
Correct |
2 ms |
504 KB |
Output is correct |
16 |
Correct |
2 ms |
632 KB |
Output is correct |
17 |
Incorrect |
16 ms |
1016 KB |
Output isn't correct |
18 |
Correct |
2 ms |
888 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 |
888 KB |
Output is correct |
23 |
Correct |
3 ms |
1144 KB |
Output is correct |
24 |
Correct |
3 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 |
4088 KB |
Output is correct |
28 |
Correct |
3 ms |
1400 KB |
Output is correct |
29 |
Incorrect |
7 ms |
5240 KB |
Output isn't correct |
30 |
Correct |
7 ms |
4220 KB |
Output is correct |
31 |
Correct |
5 ms |
3064 KB |
Output is correct |
32 |
Correct |
6 ms |
4088 KB |
Output is correct |
33 |
Correct |
8 ms |
5240 KB |
Output is correct |
34 |
Correct |
3 ms |
1784 KB |
Output is correct |
35 |
Correct |
4 ms |
2040 KB |
Output is correct |
36 |
Incorrect |
10 ms |
6648 KB |
Output isn't correct |
37 |
Correct |
2 ms |
632 KB |
Output is correct |
38 |
Correct |
157 ms |
55648 KB |
Output is correct |
39 |
Correct |
2 ms |
504 KB |
Output is correct |
40 |
Incorrect |
26 ms |
15608 KB |
Output isn't correct |
41 |
Correct |
2 ms |
504 KB |
Output is correct |
42 |
Correct |
3 ms |
1528 KB |
Output is correct |
43 |
Correct |
206 ms |
51708 KB |
Output is correct |
44 |
Correct |
9 ms |
6008 KB |
Output is correct |
45 |
Correct |
165 ms |
52984 KB |
Output is correct |
46 |
Correct |
150 ms |
55672 KB |
Output is correct |
47 |
Correct |
157 ms |
53072 KB |
Output is correct |
48 |
Incorrect |
160 ms |
55672 KB |
Output isn't correct |
49 |
Correct |
171 ms |
55580 KB |
Output is correct |
50 |
Incorrect |
150 ms |
55572 KB |
Output isn't correct |
51 |
Incorrect |
150 ms |
55464 KB |
Output isn't correct |
52 |
Correct |
148 ms |
55548 KB |
Output is correct |
53 |
Correct |
151 ms |
54908 KB |
Output is correct |
54 |
Correct |
110 ms |
42260 KB |
Output is correct |
55 |
Correct |
111 ms |
40440 KB |
Output is correct |
56 |
Correct |
148 ms |
55544 KB |
Output is correct |
57 |
Correct |
103 ms |
35576 KB |
Output is correct |
58 |
Correct |
127 ms |
40620 KB |
Output is correct |
59 |
Correct |
94 ms |
37624 KB |
Output is correct |
60 |
Correct |
149 ms |
47352 KB |
Output is correct |
61 |
Correct |
173 ms |
55604 KB |
Output is correct |
62 |
Correct |
138 ms |
55544 KB |
Output is correct |
63 |
Correct |
142 ms |
55524 KB |
Output is correct |
64 |
Correct |
106 ms |
38392 KB |
Output is correct |
65 |
Correct |
131 ms |
54520 KB |
Output is correct |
66 |
Correct |
118 ms |
51300 KB |
Output is correct |
67 |
Incorrect |
139 ms |
55516 KB |
Output isn't correct |
68 |
Incorrect |
157 ms |
55544 KB |
Output isn't correct |
69 |
Correct |
97 ms |
35192 KB |
Output is correct |
70 |
Correct |
44 ms |
15224 KB |
Output is correct |
71 |
Correct |
83 ms |
28152 KB |
Output is correct |
72 |
Correct |
101 ms |
33688 KB |
Output is correct |
73 |
Correct |
115 ms |
34040 KB |
Output is correct |
74 |
Correct |
124 ms |
35580 KB |
Output is correct |
75 |
Correct |
121 ms |
37316 KB |
Output is correct |
76 |
Correct |
129 ms |
38520 KB |
Output is correct |
77 |
Correct |
122 ms |
39032 KB |
Output is correct |
78 |
Correct |
127 ms |
39288 KB |
Output is correct |
79 |
Correct |
90 ms |
11740 KB |
Output is correct |
80 |
Correct |
83 ms |
13048 KB |
Output is correct |
81 |
Correct |
67 ms |
13560 KB |
Output is correct |
82 |
Correct |
103 ms |
41856 KB |
Output is correct |
83 |
Correct |
109 ms |
41976 KB |
Output is correct |
84 |
Correct |
56 ms |
7160 KB |
Output is correct |
85 |
Correct |
107 ms |
40924 KB |
Output is correct |
86 |
Correct |
165 ms |
54392 KB |
Output is correct |
87 |
Correct |
132 ms |
39800 KB |
Output is correct |
88 |
Correct |
101 ms |
40696 KB |
Output is correct |
89 |
Correct |
116 ms |
49528 KB |
Output is correct |
90 |
Correct |
66 ms |
29452 KB |
Output is correct |
91 |
Correct |
110 ms |
44664 KB |
Output is correct |
92 |
Correct |
113 ms |
46328 KB |
Output is correct |
93 |
Correct |
134 ms |
53496 KB |
Output is correct |
94 |
Correct |
121 ms |
48120 KB |
Output is correct |
95 |
Correct |
106 ms |
41956 KB |
Output is correct |
96 |
Correct |
104 ms |
41592 KB |
Output is correct |
97 |
Correct |
138 ms |
54360 KB |
Output is correct |
98 |
Correct |
135 ms |
41592 KB |
Output is correct |
99 |
Correct |
139 ms |
47736 KB |
Output is correct |
100 |
Correct |
162 ms |
53112 KB |
Output is correct |