#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int MN = 2525;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int N, M;
char G[MN][MN];
int cc[MN][MN][4];
int dp(int r, int c, int d) {
if(r < 0 || N <= r || c < 0 || M <= c) return 0;
int &ret = cc[r][c][d];
if(ret != -1) return ret;
if(G[r][c] == '0') return ret = 0;
return ret = dp(r + dy[d], c + dx[d], d) + 1;
}
vector<int> V[MN];
int mn[MN];
int main() {
scanf("%d %d", &N, &M);
for(int i = 0; i < N; i++) {
scanf("\n");
for(int j = 0; j < M; j++) {
scanf("%c", &G[i][j]);
}
}
memset(cc, -1, sizeof(cc));
for(int i = 0; i < N; i++) {
for(int j = 0; j < M; j++) {
if(G[i][j] == '1' && dp(i, j, 0) == 1) {
V[i].push_back(j);
}
}
}
int mnw = 1e9;
for(int i = 0; i < N; i++) for(int j = 0; j < M; j++) if(G[i][j] == '1') {
mnw = min(mnw, dp(i, j, 2) + dp(i, j, 3) - 1);
}
for(int i = 0; i <= mnw; i++) mn[i] = 1e9;
for(int i = 0; i < N; i++) for(int j = 0; j < M; j++) if(G[i][j] == '1') {
int a = lower_bound(V[i].begin(), V[i].end(), j) - V[i].begin();
int b = a - 1;
int l = j - dp(i, j, 3) + 1;
int r = j + dp(i, j, 2) - 1;
if(a != V[i].size() && V[i][a] <= r) {
mn[ V[i][a] - j + 1 ] = min(mn[ V[i][a] - j + 1 ], dp(i, j, 1));
}
if(b != -1 && l <= V[i][b]) {
mn[ j - V[i][b] + 1 ] = min(mn[ j - V[i][b] + 1 ], dp(i, j, 1));
}
}
int ans = 0;
for(int i = 1; i <= mnw; i++) {
mn[i] = min(mn[i], mn[i - 1]);
ans = max(ans, mn[i] * i);
}
printf("%d", ans);
}
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:58:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(a != V[i].size() && V[i][a] <= r) {
~~^~~~~~~~~~~~~~
bomb.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &N, &M);
~~~~~^~~~~~~~~~~~~~~~~
bomb.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("\n");
~~~~~^~~~~~
bomb.cpp:32:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%c", &G[i][j]);
~~~~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
70 ms |
100216 KB |
Output is correct |
2 |
Correct |
71 ms |
100216 KB |
Output is correct |
3 |
Correct |
74 ms |
106360 KB |
Output is correct |
4 |
Correct |
73 ms |
106364 KB |
Output is correct |
5 |
Correct |
81 ms |
100216 KB |
Output is correct |
6 |
Correct |
73 ms |
100256 KB |
Output is correct |
7 |
Correct |
70 ms |
100216 KB |
Output is correct |
8 |
Incorrect |
69 ms |
100216 KB |
Output isn't correct |
9 |
Incorrect |
74 ms |
100236 KB |
Output isn't correct |
10 |
Correct |
80 ms |
100216 KB |
Output is correct |
11 |
Incorrect |
70 ms |
100216 KB |
Output isn't correct |
12 |
Correct |
80 ms |
100208 KB |
Output is correct |
13 |
Correct |
70 ms |
100216 KB |
Output is correct |
14 |
Correct |
69 ms |
100216 KB |
Output is correct |
15 |
Incorrect |
70 ms |
100216 KB |
Output isn't correct |
16 |
Correct |
82 ms |
100216 KB |
Output is correct |
17 |
Incorrect |
72 ms |
100344 KB |
Output isn't correct |
18 |
Correct |
80 ms |
100348 KB |
Output is correct |
19 |
Incorrect |
93 ms |
100436 KB |
Output isn't correct |
20 |
Incorrect |
79 ms |
100388 KB |
Output isn't correct |
21 |
Correct |
74 ms |
100308 KB |
Output is correct |
22 |
Correct |
78 ms |
100344 KB |
Output is correct |
23 |
Incorrect |
71 ms |
100472 KB |
Output isn't correct |
24 |
Incorrect |
73 ms |
100344 KB |
Output isn't correct |
25 |
Incorrect |
70 ms |
100444 KB |
Output isn't correct |
26 |
Correct |
70 ms |
100472 KB |
Output is correct |
27 |
Correct |
79 ms |
100856 KB |
Output is correct |
28 |
Correct |
75 ms |
100984 KB |
Output is correct |
29 |
Correct |
80 ms |
101240 KB |
Output is correct |
30 |
Incorrect |
90 ms |
101468 KB |
Output isn't correct |
31 |
Incorrect |
78 ms |
100984 KB |
Output isn't correct |
32 |
Incorrect |
77 ms |
101240 KB |
Output isn't correct |
33 |
Incorrect |
82 ms |
101368 KB |
Output isn't correct |
34 |
Correct |
79 ms |
101068 KB |
Output is correct |
35 |
Incorrect |
84 ms |
101468 KB |
Output isn't correct |
36 |
Incorrect |
87 ms |
101468 KB |
Output isn't correct |
37 |
Incorrect |
80 ms |
100188 KB |
Output isn't correct |
38 |
Correct |
996 ms |
107440 KB |
Output is correct |
39 |
Incorrect |
69 ms |
100216 KB |
Output isn't correct |
40 |
Incorrect |
146 ms |
102908 KB |
Output isn't correct |
41 |
Incorrect |
70 ms |
100216 KB |
Output isn't correct |
42 |
Incorrect |
79 ms |
100432 KB |
Output isn't correct |
43 |
Correct |
648 ms |
107512 KB |
Output is correct |
44 |
Incorrect |
94 ms |
101496 KB |
Output isn't correct |
45 |
Incorrect |
601 ms |
107484 KB |
Output isn't correct |
46 |
Correct |
494 ms |
108224 KB |
Output is correct |
47 |
Incorrect |
599 ms |
107384 KB |
Output isn't correct |
48 |
Incorrect |
569 ms |
107512 KB |
Output isn't correct |
49 |
Correct |
733 ms |
107384 KB |
Output is correct |
50 |
Incorrect |
650 ms |
107512 KB |
Output isn't correct |
51 |
Incorrect |
640 ms |
107356 KB |
Output isn't correct |
52 |
Incorrect |
556 ms |
107424 KB |
Output isn't correct |
53 |
Incorrect |
547 ms |
107512 KB |
Output isn't correct |
54 |
Correct |
465 ms |
107496 KB |
Output is correct |
55 |
Correct |
436 ms |
107384 KB |
Output is correct |
56 |
Correct |
969 ms |
107768 KB |
Output is correct |
57 |
Correct |
505 ms |
107640 KB |
Output is correct |
58 |
Correct |
463 ms |
107452 KB |
Output is correct |
59 |
Correct |
533 ms |
107512 KB |
Output is correct |
60 |
Correct |
577 ms |
107540 KB |
Output is correct |
61 |
Correct |
783 ms |
107640 KB |
Output is correct |
62 |
Correct |
935 ms |
107768 KB |
Output is correct |
63 |
Correct |
888 ms |
107632 KB |
Output is correct |
64 |
Correct |
492 ms |
107512 KB |
Output is correct |
65 |
Incorrect |
598 ms |
107516 KB |
Output isn't correct |
66 |
Incorrect |
575 ms |
107676 KB |
Output isn't correct |
67 |
Incorrect |
618 ms |
107640 KB |
Output isn't correct |
68 |
Incorrect |
687 ms |
107640 KB |
Output isn't correct |
69 |
Correct |
466 ms |
107500 KB |
Output is correct |
70 |
Incorrect |
262 ms |
105724 KB |
Output isn't correct |
71 |
Incorrect |
384 ms |
107448 KB |
Output isn't correct |
72 |
Incorrect |
416 ms |
107384 KB |
Output isn't correct |
73 |
Incorrect |
417 ms |
107412 KB |
Output isn't correct |
74 |
Incorrect |
415 ms |
107384 KB |
Output isn't correct |
75 |
Incorrect |
469 ms |
107480 KB |
Output isn't correct |
76 |
Incorrect |
429 ms |
107384 KB |
Output isn't correct |
77 |
Incorrect |
522 ms |
107416 KB |
Output isn't correct |
78 |
Incorrect |
442 ms |
107516 KB |
Output isn't correct |
79 |
Incorrect |
329 ms |
107384 KB |
Output isn't correct |
80 |
Incorrect |
320 ms |
107512 KB |
Output isn't correct |
81 |
Incorrect |
326 ms |
107468 KB |
Output isn't correct |
82 |
Incorrect |
432 ms |
107512 KB |
Output isn't correct |
83 |
Incorrect |
435 ms |
107512 KB |
Output isn't correct |
84 |
Incorrect |
357 ms |
107512 KB |
Output isn't correct |
85 |
Incorrect |
431 ms |
107604 KB |
Output isn't correct |
86 |
Incorrect |
914 ms |
107448 KB |
Output isn't correct |
87 |
Correct |
516 ms |
107452 KB |
Output is correct |
88 |
Incorrect |
487 ms |
107384 KB |
Output isn't correct |
89 |
Incorrect |
614 ms |
107512 KB |
Output isn't correct |
90 |
Incorrect |
353 ms |
106232 KB |
Output isn't correct |
91 |
Incorrect |
502 ms |
107384 KB |
Output isn't correct |
92 |
Incorrect |
563 ms |
107512 KB |
Output isn't correct |
93 |
Incorrect |
885 ms |
107552 KB |
Output isn't correct |
94 |
Incorrect |
573 ms |
107464 KB |
Output isn't correct |
95 |
Incorrect |
476 ms |
107576 KB |
Output isn't correct |
96 |
Incorrect |
489 ms |
107556 KB |
Output isn't correct |
97 |
Execution timed out |
1045 ms |
107396 KB |
Time limit exceeded |
98 |
Incorrect |
466 ms |
107356 KB |
Output isn't correct |
99 |
Incorrect |
565 ms |
106640 KB |
Output isn't correct |
100 |
Incorrect |
792 ms |
106744 KB |
Output isn't correct |