Submission #43149

# Submission time Handle Problem Language Result Execution time Memory
43149 2018-03-09T14:47:22 Z cheater2k Bomb (IZhO17_bomb) C++14
93 / 100
513 ms 131072 KB
/*
5 5 
00111
00111
11111
11110
11100
*/
#include <bits/stdc++.h>
using namespace std;

#define left __left
#define right __right

const int N = 2505;

int n, m, nrow, ncol;
int left[N][N];
int right[N][N];
int up[N][N];
int down[N][N];
char a[N][N];
int c[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			cin >> a[i][j];
		}
	}

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) left[i][j] = a[i][j] == '1' ? left[i][j - 1] + 1 : 0;
		for (int j = m; j >= 1; --j) right[i][j] = a[i][j] == '1' ? right[i][j + 1] + 1 : 0;
	}

	for (int j = 1; j <= m; ++j) {
		for (int i = 1; i <= n; ++i) up[i][j] = a[i][j] == '1' ? up[i - 1][j] + 1 : 0;
		for (int i = n; i >= 1; --i) down[i][j] = a[i][j] == '1' ? down[i + 1][j] + 1 : 0;
	}

	nrow = n, ncol = m;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) if (a[i][j] == '1') {
			nrow = min(nrow, up[i][j] + down[i][j] - 1);
			ncol = min(ncol, left[i][j] + right[i][j] - 1);
		}
	}

	int res = 0;
	for (int r = 1; r <= nrow; ++r) c[r] = ncol;

	for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) {
		if (a[i][j] != '1') continue;

		if (down[i][j] == 1) {
			for (int k = i; k >= i - nrow + 1; --k) {
				if (left[i][j] == 1) c[i - k + 1] = min(c[i - k + 1], right[k][j]);
				if (right[i][j] == 1) c[i - k + 1] = min(c[i - k + 1], left[k][j]);
			}
		} else if (up[i][j] == 1) {
			for (int k = i; k <= i + nrow - 1; ++k) {
				if (left[i][j] == 1) c[k - i + 1] = min(c[k - i + 1], right[k][j]);
				if (right[i][j] == 1) c[k - i + 1] = min(c[k - i + 1], left[k][j]);
			}
		}
	}

	for (int r = 1; r <= nrow; ++r) res = max(res, r * c[r]);
	cout << res << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 740 KB Output is correct
3 Correct 38 ms 46920 KB Output is correct
4 Correct 39 ms 46920 KB Output is correct
5 Correct 2 ms 46920 KB Output is correct
6 Correct 2 ms 46920 KB Output is correct
7 Correct 2 ms 46920 KB Output is correct
8 Correct 2 ms 46920 KB Output is correct
9 Correct 2 ms 46920 KB Output is correct
10 Correct 2 ms 46920 KB Output is correct
11 Correct 2 ms 46920 KB Output is correct
12 Correct 2 ms 46920 KB Output is correct
13 Correct 2 ms 46920 KB Output is correct
14 Correct 2 ms 46920 KB Output is correct
15 Correct 2 ms 46920 KB Output is correct
16 Correct 2 ms 46920 KB Output is correct
17 Correct 2 ms 46920 KB Output is correct
18 Correct 3 ms 46920 KB Output is correct
19 Correct 3 ms 46920 KB Output is correct
20 Correct 3 ms 46920 KB Output is correct
21 Correct 2 ms 46920 KB Output is correct
22 Correct 3 ms 46920 KB Output is correct
23 Correct 3 ms 46920 KB Output is correct
24 Correct 3 ms 46920 KB Output is correct
25 Correct 3 ms 46920 KB Output is correct
26 Correct 3 ms 46920 KB Output is correct
27 Correct 10 ms 46920 KB Output is correct
28 Correct 9 ms 46920 KB Output is correct
29 Incorrect 12 ms 46920 KB Output isn't correct
30 Correct 14 ms 46920 KB Output is correct
31 Correct 11 ms 46920 KB Output is correct
32 Correct 12 ms 46920 KB Output is correct
33 Correct 15 ms 46920 KB Output is correct
34 Correct 8 ms 46920 KB Output is correct
35 Correct 14 ms 46920 KB Output is correct
36 Correct 16 ms 46920 KB Output is correct
37 Correct 2 ms 46920 KB Output is correct
38 Correct 466 ms 112668 KB Output is correct
39 Correct 2 ms 112668 KB Output is correct
40 Incorrect 55 ms 112668 KB Output isn't correct
41 Correct 2 ms 112668 KB Output is correct
42 Correct 3 ms 112668 KB Output is correct
43 Correct 468 ms 119628 KB Output is correct
44 Correct 16 ms 119628 KB Output is correct
45 Correct 500 ms 125816 KB Output is correct
46 Correct 513 ms 131072 KB Output is correct
47 Correct 466 ms 131072 KB Output is correct
48 Incorrect 452 ms 131072 KB Output isn't correct
49 Correct 459 ms 131072 KB Output is correct
50 Incorrect 507 ms 131072 KB Output isn't correct
51 Incorrect 464 ms 131072 KB Output isn't correct
52 Correct 449 ms 131072 KB Output is correct
53 Correct 447 ms 131072 KB Output is correct
54 Correct 429 ms 131072 KB Output is correct
55 Correct 420 ms 131072 KB Output is correct
56 Correct 492 ms 131072 KB Output is correct
57 Correct 440 ms 131072 KB Output is correct
58 Correct 448 ms 131072 KB Output is correct
59 Correct 429 ms 131072 KB Output is correct
60 Correct 439 ms 131072 KB Output is correct
61 Correct 445 ms 131072 KB Output is correct
62 Correct 495 ms 131072 KB Output is correct
63 Correct 486 ms 131072 KB Output is correct
64 Correct 421 ms 131072 KB Output is correct
65 Correct 447 ms 131072 KB Output is correct
66 Correct 442 ms 131072 KB Output is correct
67 Incorrect 445 ms 131072 KB Output isn't correct
68 Incorrect 463 ms 131072 KB Output isn't correct
69 Correct 445 ms 131072 KB Output is correct
70 Correct 287 ms 131072 KB Output is correct
71 Correct 449 ms 131072 KB Output is correct
72 Correct 456 ms 131072 KB Output is correct
73 Correct 421 ms 131072 KB Output is correct
74 Correct 430 ms 131072 KB Output is correct
75 Correct 439 ms 131072 KB Output is correct
76 Correct 434 ms 131072 KB Output is correct
77 Correct 509 ms 131072 KB Output is correct
78 Correct 427 ms 131072 KB Output is correct
79 Correct 410 ms 131072 KB Output is correct
80 Correct 430 ms 131072 KB Output is correct
81 Correct 402 ms 131072 KB Output is correct
82 Correct 440 ms 131072 KB Output is correct
83 Correct 419 ms 131072 KB Output is correct
84 Correct 431 ms 131072 KB Output is correct
85 Correct 421 ms 131072 KB Output is correct
86 Correct 464 ms 131072 KB Output is correct
87 Correct 424 ms 131072 KB Output is correct
88 Correct 430 ms 131072 KB Output is correct
89 Correct 449 ms 131072 KB Output is correct
90 Correct 281 ms 131072 KB Output is correct
91 Correct 437 ms 131072 KB Output is correct
92 Correct 435 ms 131072 KB Output is correct
93 Correct 448 ms 131072 KB Output is correct
94 Correct 445 ms 131072 KB Output is correct
95 Correct 436 ms 131072 KB Output is correct
96 Correct 427 ms 131072 KB Output is correct
97 Correct 447 ms 131072 KB Output is correct
98 Correct 422 ms 131072 KB Output is correct
99 Correct 429 ms 131072 KB Output is correct
100 Correct 448 ms 131072 KB Output is correct