# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
93220 |
2019-01-07T10:03:07 Z |
Vardanyan |
Bomb (IZhO17_bomb) |
C++14 |
|
348 ms |
106432 KB |
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <vector>
using namespace std;
const int N = 2505;
int dzaxic[N][N];
int ajic[N][N];
int a[N][N];
int n, m;
int M[N];
int mnw = 1000 * 1000 * 1000 + 5;
int mnh = mnw;
vector<pair<int, int> > v;
int main(){
ios_base::sync_with_stdio(false);
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++)
{
int now = 0;
for (int j = 1; j <= m; j++){
if (a[i][j]){
now++;
dzaxic[i][j] = now;
}
else{
if (now) mnw = min(mnw, now);
now = 0;
}
}
if (now) mnw = min(mnw, now);
now = 0;
for (int j = m; j >= 1; j--){
if (a[i][j]){
now++;
ajic[i][j] = now;
}
else{
if (now) mnw = min(mnw, now);
now = 0;
}
}
if (now) mnw = min(mnw, now);
now = 0;
}
for (int j = 1; j <= m; j++){
int now = 0;
for (int i = 1; i <= n; i++){
if (a[i][j]){
now++;
}
else{
if (now) mnh = min(mnh, now);
now = 0;
}
}
if (now) mnh = min(mnh, now);
}
//cout << mnh << " " << mnw << endl;
/*for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
cout <<ajic[i][j] << " ";
}
cout << endl;
}*/
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
if (a[i][j] == 1 && a[i - 1][j] == 0 && a[i][j - 1] == 0 && a[i - 1][j - 1] == 0){
int now = -1;
//calc1(i, j, 1);
for (int ii = i; ii <= n; ii++){
if (a[ii][j] == 0) break;
if (now == -1 || ajic[ii][j] < now){
now = ajic[ii][j];
}
now = min(now, mnw);
v.push_back({ ii - i + 1, now });
}
}
if (a[i][j] == 1 && a[i][j - 1] == 0 && a[i + 1][j - 1] == 0 && a[i][j + 1] == 0){
int now = -1;
//calc1(i, j, -1);
for (int ii = i; ii >= 1; ii--){
if (a[ii][j] == 0) break;
if (now == -1 || ajic[ii][j] < now){
now = ajic[ii][j];
}
now = min(now, mnw);
v.push_back({ i - ii + 1, now });
}
}
if (a[i][j] == 1 && a[i - 1][j] == 0 && a[i][j + 1] == 0 && a[i - 1][j + 1] == 0){
int now = -1;
for (int ii = i; ii <= n; ii++){
if (a[ii][j] == 0) break;
if (now == -1 || dzaxic[ii][j] < now){
now = dzaxic[ii][j];
}
now = min(now, mnw);
v.push_back({ ii - i + 1, now });
}
}
if (a[i][j] == 1 && a[i + 1][j] == 0 && a[i][j + 1] == 0 && a[i + 1][j + 1] == 0){
int now = -1;
for (int ii = i; ii >= 1; ii--){
if (a[ii][j] == 0) break;
if (now == -1 || dzaxic[ii][j] < now){
now = dzaxic[ii][j];
}
now = min(now, mnw);
v.push_back({ i - ii + 1, now });
}
}
}
}
// cout << mnh << " " << mnw << endl;
memset(M, -1, sizeof M);
for (int i = 0; i < v.size(); i++){
int a = v[i].first;
int b = v[i].second;
b = min(b, mnw);
if (M[a] == -1 || M[a] > b){
M[a] = b;
}
}
int ans = 0;
for (int i = 0; i < v.size(); i++){
int a = v[i].first;
if (a > mnh) continue;
int b = M[a];
a *= b;
ans = max(ans, a);
}
cout << ans << endl;
return 0;
}
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:128:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v.size(); i++){
~~^~~~~~~~~~
bomb.cpp:137:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v.size(); i++){
~~^~~~~~~~~~
# |
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 |
63 ms |
46932 KB |
Output is correct |
4 |
Correct |
41 ms |
38724 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 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
10 |
Correct |
2 ms |
508 KB |
Output is correct |
11 |
Incorrect |
2 ms |
632 KB |
Output isn't correct |
12 |
Correct |
2 ms |
504 KB |
Output is correct |
13 |
Correct |
2 ms |
504 KB |
Output is correct |
14 |
Correct |
2 ms |
632 KB |
Output is correct |
15 |
Correct |
2 ms |
504 KB |
Output is correct |
16 |
Correct |
2 ms |
632 KB |
Output is correct |
17 |
Correct |
2 ms |
1272 KB |
Output is correct |
18 |
Correct |
2 ms |
888 KB |
Output is correct |
19 |
Incorrect |
2 ms |
1272 KB |
Output isn't correct |
20 |
Correct |
2 ms |
1272 KB |
Output is correct |
21 |
Correct |
2 ms |
760 KB |
Output is correct |
22 |
Correct |
2 ms |
1016 KB |
Output is correct |
23 |
Incorrect |
2 ms |
1272 KB |
Output isn't correct |
24 |
Incorrect |
3 ms |
1272 KB |
Output isn't correct |
25 |
Correct |
2 ms |
1656 KB |
Output is correct |
26 |
Correct |
3 ms |
1656 KB |
Output is correct |
27 |
Correct |
7 ms |
4984 KB |
Output is correct |
28 |
Correct |
6 ms |
2424 KB |
Output is correct |
29 |
Correct |
10 ms |
7004 KB |
Output is correct |
30 |
Incorrect |
9 ms |
5880 KB |
Output isn't correct |
31 |
Incorrect |
8 ms |
4472 KB |
Output isn't correct |
32 |
Incorrect |
8 ms |
5624 KB |
Output isn't correct |
33 |
Correct |
10 ms |
7032 KB |
Output is correct |
34 |
Correct |
5 ms |
2680 KB |
Output is correct |
35 |
Incorrect |
8 ms |
3704 KB |
Output isn't correct |
36 |
Correct |
12 ms |
8356 KB |
Output is correct |
37 |
Correct |
2 ms |
632 KB |
Output is correct |
38 |
Correct |
224 ms |
77288 KB |
Output is correct |
39 |
Correct |
2 ms |
632 KB |
Output is correct |
40 |
Incorrect |
38 ms |
20856 KB |
Output isn't correct |
41 |
Correct |
2 ms |
632 KB |
Output is correct |
42 |
Correct |
3 ms |
1656 KB |
Output is correct |
43 |
Correct |
348 ms |
106432 KB |
Output is correct |
44 |
Correct |
12 ms |
8312 KB |
Output is correct |
45 |
Correct |
289 ms |
91768 KB |
Output is correct |
46 |
Correct |
231 ms |
77944 KB |
Output is correct |
47 |
Correct |
261 ms |
91740 KB |
Output is correct |
48 |
Correct |
222 ms |
81940 KB |
Output is correct |
49 |
Correct |
219 ms |
77816 KB |
Output is correct |
50 |
Correct |
242 ms |
81896 KB |
Output is correct |
51 |
Correct |
251 ms |
82080 KB |
Output is correct |
52 |
Correct |
254 ms |
81896 KB |
Output is correct |
53 |
Correct |
239 ms |
81384 KB |
Output is correct |
54 |
Correct |
228 ms |
66556 KB |
Output is correct |
55 |
Correct |
202 ms |
64908 KB |
Output is correct |
56 |
Correct |
247 ms |
81976 KB |
Output is correct |
57 |
Correct |
216 ms |
59076 KB |
Output is correct |
58 |
Correct |
210 ms |
65184 KB |
Output is correct |
59 |
Correct |
226 ms |
60960 KB |
Output is correct |
60 |
Correct |
218 ms |
70008 KB |
Output is correct |
61 |
Correct |
218 ms |
77984 KB |
Output is correct |
62 |
Correct |
233 ms |
78200 KB |
Output is correct |
63 |
Correct |
204 ms |
78256 KB |
Output is correct |
64 |
Correct |
194 ms |
61048 KB |
Output is correct |
65 |
Correct |
243 ms |
81036 KB |
Output is correct |
66 |
Correct |
224 ms |
73976 KB |
Output is correct |
67 |
Correct |
245 ms |
82104 KB |
Output is correct |
68 |
Correct |
246 ms |
82024 KB |
Output is correct |
69 |
Correct |
220 ms |
58176 KB |
Output is correct |
70 |
Incorrect |
120 ms |
33572 KB |
Output isn't correct |
71 |
Incorrect |
188 ms |
48504 KB |
Output isn't correct |
72 |
Correct |
216 ms |
52088 KB |
Output is correct |
73 |
Incorrect |
214 ms |
52600 KB |
Output isn't correct |
74 |
Incorrect |
216 ms |
58140 KB |
Output isn't correct |
75 |
Incorrect |
214 ms |
59512 KB |
Output isn't correct |
76 |
Correct |
219 ms |
60920 KB |
Output is correct |
77 |
Correct |
224 ms |
61412 KB |
Output is correct |
78 |
Correct |
219 ms |
61616 KB |
Output is correct |
79 |
Incorrect |
182 ms |
33912 KB |
Output isn't correct |
80 |
Incorrect |
197 ms |
35324 KB |
Output isn't correct |
81 |
Incorrect |
178 ms |
35720 KB |
Output isn't correct |
82 |
Correct |
198 ms |
63908 KB |
Output is correct |
83 |
Incorrect |
223 ms |
64396 KB |
Output isn't correct |
84 |
Incorrect |
194 ms |
29348 KB |
Output isn't correct |
85 |
Incorrect |
217 ms |
63352 KB |
Output isn't correct |
86 |
Incorrect |
219 ms |
76400 KB |
Output isn't correct |
87 |
Correct |
219 ms |
62200 KB |
Output is correct |
88 |
Incorrect |
219 ms |
63064 KB |
Output isn't correct |
89 |
Incorrect |
224 ms |
71544 KB |
Output isn't correct |
90 |
Incorrect |
145 ms |
47984 KB |
Output isn't correct |
91 |
Correct |
224 ms |
66680 KB |
Output is correct |
92 |
Correct |
218 ms |
68344 KB |
Output is correct |
93 |
Correct |
223 ms |
75256 KB |
Output is correct |
94 |
Incorrect |
207 ms |
69880 KB |
Output isn't correct |
95 |
Incorrect |
196 ms |
63864 KB |
Output isn't correct |
96 |
Incorrect |
217 ms |
63480 KB |
Output isn't correct |
97 |
Correct |
215 ms |
75948 KB |
Output is correct |
98 |
Correct |
218 ms |
63352 KB |
Output is correct |
99 |
Incorrect |
231 ms |
69604 KB |
Output isn't correct |
100 |
Incorrect |
221 ms |
74976 KB |
Output isn't correct |