답안 #768228

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
768228 2023-06-27T18:47:30 Z rainboy Bomb (IZhO17_bomb) C
100 / 100
426 ms 110540 KB
#include <stdio.h>

#define N	2500
#define M	2500

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

int main() {
	static char cc[N][M + 1];
	static int ll[N][M], rr[N][M], uu[N][M], dd[N][M], yy[N + 1];
	int n, m, i, i_, j, j_, l, r, u, d, x, y, ans;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%s", cc[i]);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++)
			ll[i][j] = cc[i][j] == '0' ? j + 1 : (j == 0 ? 0 : ll[i][j - 1]);
		for (j = m - 1; j >= 0; j--)
			rr[i][j] = cc[i][j] == '0' ? j - 1 : (j + 1 == m ? m - 1 : rr[i][j + 1]);
	}
	for (j = 0; j < m; j++) {
		for (i = 0; i < n; i++)
			uu[i][j] = cc[i][j] == '0' ? i + 1 : (i == 0 ? 0 : uu[i - 1][j]);
		for (i = n - 1; i >= 0; i--)
			dd[i][j] = cc[i][j] == '0' ? i - 1 : (i + 1 == n ? n - 1 : dd[i + 1][j]);
	}
	for (x = 1; x <= n; x++)
		yy[x] = m;
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++) {
			if (ll[i][j] == j) {
				j_ = j, u = 0, d = n - 1;
				while (j_ <= rr[i][j]) {
					u = max(u, uu[i][j_]), d = min(d, dd[i][j_]);
					x = d - u + 1, y = j_ - j;
					if (x < n)
						yy[x + 1] = min(yy[x + 1], y);
					j_++;
				}
				x = 0, y = j_ - j;
				if (x < n)
					yy[x + 1] = min(yy[x + 1], y);
			}
			if (rr[i][j] == j) {
				j_ = j, u = 0, d = n - 1;
				while (j_ >= ll[i][j]) {
					u = max(u, uu[i][j_]), d = min(d, dd[i][j_]);
					x = d - u + 1, y = j - j_;
					if (x < n)
						yy[x + 1] = min(yy[x + 1], y);
					j_--;
				}
				x = 0, y = j - j_;
				if (x < n)
					yy[x + 1] = min(yy[x + 1], y);
			}
			if (uu[i][j] == i) {
				i_ = i, l = 0, r = m - 1;
				while (i_ <= dd[i][j]) {
					l = max(l, ll[i_][j]), r = max(r, rr[i_][j]);
					x = i_ - i, y = r - l + 1;
					if (x < n)
						yy[x + 1] = min(yy[x + 1], y);
					i_++;
				}
				x = i_ - i, y = 0;
				if (x < n)
					yy[x + 1] = min(yy[x + 1], y);
			}
			if (dd[i][j] == i) {
				i_ = i, l = 0, r = m - 1;
				while (i_ >= uu[i][j]) {
					l = max(l, ll[i_][j]), r = max(r, rr[i_][j]);
					x = i - i_, y = r - l + 1;
					if (x < n)
						yy[x + 1] = min(yy[x + 1], y);
					i_--;
				}
				x = i - i_, y = 0;
				if (x < n)
					yy[x + 1] = min(yy[x + 1], y);
			}
		}
	y = m, ans = 0;
	for (x = 1; x <= n; x++) {
		y = min(y, yy[x]);
		ans = max(ans, x * y);
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

bomb.c: In function 'main':
bomb.c:14:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
bomb.c:16:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%s", cc[i]);
      |   ^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 16 ms 46548 KB Output is correct
4 Correct 14 ms 46504 KB Output is correct
5 Correct 1 ms 288 KB Output is correct
6 Correct 1 ms 288 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 676 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 548 KB Output is correct
14 Correct 1 ms 548 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 1492 KB Output is correct
18 Correct 1 ms 1620 KB Output is correct
19 Correct 1 ms 2088 KB Output is correct
20 Correct 1 ms 2088 KB Output is correct
21 Correct 1 ms 1364 KB Output is correct
22 Correct 1 ms 1836 KB Output is correct
23 Correct 1 ms 2260 KB Output is correct
24 Correct 1 ms 1836 KB Output is correct
25 Correct 1 ms 2260 KB Output is correct
26 Correct 1 ms 2260 KB Output is correct
27 Correct 4 ms 6996 KB Output is correct
28 Correct 3 ms 7508 KB Output is correct
29 Correct 6 ms 9576 KB Output is correct
30 Correct 6 ms 11308 KB Output is correct
31 Correct 5 ms 8976 KB Output is correct
32 Correct 6 ms 10324 KB Output is correct
33 Correct 7 ms 11860 KB Output is correct
34 Correct 4 ms 8236 KB Output is correct
35 Correct 6 ms 11940 KB Output is correct
36 Correct 9 ms 11984 KB Output is correct
37 Correct 1 ms 596 KB Output is correct
38 Correct 392 ms 110332 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 35 ms 29208 KB Output is correct
41 Correct 1 ms 596 KB Output is correct
42 Correct 1 ms 2260 KB Output is correct
43 Correct 327 ms 110364 KB Output is correct
44 Correct 8 ms 11988 KB Output is correct
45 Correct 308 ms 110336 KB Output is correct
46 Correct 232 ms 110348 KB Output is correct
47 Correct 318 ms 110448 KB Output is correct
48 Correct 278 ms 110244 KB Output is correct
49 Correct 426 ms 110284 KB Output is correct
50 Correct 292 ms 110360 KB Output is correct
51 Correct 305 ms 110460 KB Output is correct
52 Correct 272 ms 110332 KB Output is correct
53 Correct 274 ms 110348 KB Output is correct
54 Correct 240 ms 110332 KB Output is correct
55 Correct 234 ms 110328 KB Output is correct
56 Correct 371 ms 110248 KB Output is correct
57 Correct 236 ms 110324 KB Output is correct
58 Correct 237 ms 110320 KB Output is correct
59 Correct 224 ms 110328 KB Output is correct
60 Correct 280 ms 110328 KB Output is correct
61 Correct 406 ms 110460 KB Output is correct
62 Correct 377 ms 110332 KB Output is correct
63 Correct 389 ms 110336 KB Output is correct
64 Correct 213 ms 110348 KB Output is correct
65 Correct 278 ms 110348 KB Output is correct
66 Correct 275 ms 110344 KB Output is correct
67 Correct 299 ms 110332 KB Output is correct
68 Correct 309 ms 110332 KB Output is correct
69 Correct 235 ms 110324 KB Output is correct
70 Correct 114 ms 87244 KB Output is correct
71 Correct 202 ms 110320 KB Output is correct
72 Correct 227 ms 110344 KB Output is correct
73 Correct 214 ms 110328 KB Output is correct
74 Correct 216 ms 110340 KB Output is correct
75 Correct 210 ms 110332 KB Output is correct
76 Correct 227 ms 110540 KB Output is correct
77 Correct 239 ms 110348 KB Output is correct
78 Correct 226 ms 110256 KB Output is correct
79 Correct 186 ms 110512 KB Output is correct
80 Correct 179 ms 110284 KB Output is correct
81 Correct 181 ms 110324 KB Output is correct
82 Correct 224 ms 110356 KB Output is correct
83 Correct 227 ms 110324 KB Output is correct
84 Correct 183 ms 110344 KB Output is correct
85 Correct 229 ms 110328 KB Output is correct
86 Correct 380 ms 110284 KB Output is correct
87 Correct 225 ms 110468 KB Output is correct
88 Correct 235 ms 110348 KB Output is correct
89 Correct 277 ms 110352 KB Output is correct
90 Correct 160 ms 87324 KB Output is correct
91 Correct 250 ms 110316 KB Output is correct
92 Correct 277 ms 110340 KB Output is correct
93 Correct 377 ms 110324 KB Output is correct
94 Correct 289 ms 110336 KB Output is correct
95 Correct 239 ms 110448 KB Output is correct
96 Correct 243 ms 110340 KB Output is correct
97 Correct 397 ms 110284 KB Output is correct
98 Correct 247 ms 110332 KB Output is correct
99 Correct 310 ms 110452 KB Output is correct
100 Correct 404 ms 110248 KB Output is correct