답안 #878847

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878847 2023-11-25T10:38:39 Z SanguineChameleon 축구 경기장 (IOI23_soccer) C++17
70 / 100
4500 ms 175996 KB
#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;

const int maxN = 2e3 + 20;
int A[maxN][maxN];
int prv[maxN][maxN][2];
int top[maxN][maxN];
int bottom[maxN][maxN];
vector<pair<int, int>> group[maxN];
int dp[maxN][maxN];

int biggest_stadium(int N, vector<vector<int>> _A) {
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			A[i][j] = _A[i - 1][j - 1];
		}
	}
	for (int i = 0; i <= N + 1; i++) {
		A[0][i] = 1;
		A[N + 1][i] = 1;
		A[i][0] = 1;
		A[i][N + 1] = 1;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			for (int k = 0; k < 2; k++) {
				if (A[i][j] == k) {
					prv[i][j][k] = j;
				}
				else {
					prv[i][j][k] = prv[i][j - 1][k];
				}
			}
		}
	}
	for (int j = 0; j <= N; j++) {
		top[0][j] = 0;
		bottom[N + 1][j] = N + 1;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			if (A[i - 1][j] == 1) {
				top[i][j] = i - 1;
			}
			else {
				top[i][j] = top[i - 1][j];
			}
		}
	}
	for (int i = N; i >= 1; i--) {
		for (int j = 0; j <= N; j++) {
			if (A[i + 1][j] == 1) {
				bottom[i][j] = i + 1;
			}
			else {
				bottom[i][j] = bottom[i + 1][j];
			}
		}
	}
	for (int i = N; i >= 1; i--) {
		for (int j = 1; j <= N; j++) {
			if (A[i][j] == 0) {
				if (A[i][j - 1] == 0) {
					top[i][j] = max(top[i][j], top[i][j - 1]);
					bottom[i][j] = min(bottom[i][j], bottom[i][j - 1]);
				}
				group[j - prv[i][j][1]].emplace_back(i, j);
			}
		}
	}
	int res = 0;
	for (int W = N; W >= 1; W--) {
		for (auto [i, j]: group[W]) {
			if (top[i][j] + 1 <= top[i][prv[i][j][1]]) {
				dp[top[i][prv[i][j][1]]][j] = max(dp[top[i][prv[i][j][1]]][j], dp[i][j]);
				continue;
			}
			int L = prv[i][j][1] + 1;
			int R = j;
			int T = top[i][j] + 1;
			int B = bottom[i][j] - 1;
			res = max(res, dp[i][j] + (R - L + 1) * (B - T + 1));
			for (int iter = 0; iter < 2; iter++) {
				int row = (iter ? B + 1 : T - 1);
				if (row < 1 || row > N) {
					continue;
				}
				int nxtR = prv[row][R][0];
				while (nxtR >= L) {
					int nxtL = max(L, prv[row][nxtR][1] + 1);
					int nxt_row = (nxtL == L ? i : row); 
					dp[nxt_row][nxtR] = max(dp[nxt_row][nxtR], dp[i][j] + ((R - L + 1) - (nxtR - nxtL + 1)) * (B - T + 1));
					nxtR = prv[row][nxtL - 1][0];
				}
			}
		}
	}
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8540 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8540 KB ok
2 Correct 1 ms 8540 KB ok
3 Correct 2 ms 6492 KB ok
4 Correct 1 ms 8540 KB ok
5 Correct 1 ms 8644 KB ok
6 Correct 1 ms 8540 KB ok
7 Correct 3 ms 15316 KB ok
8 Correct 28 ms 36444 KB ok
9 Correct 412 ms 167508 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8540 KB ok
2 Correct 1 ms 8540 KB ok
3 Correct 1 ms 8540 KB ok
4 Correct 1 ms 8536 KB ok
5 Correct 1 ms 8540 KB ok
6 Correct 1 ms 6492 KB ok
7 Correct 1 ms 8540 KB ok
8 Correct 1 ms 8540 KB ok
9 Correct 1 ms 8540 KB ok
10 Correct 1 ms 8540 KB ok
11 Correct 1 ms 8540 KB ok
12 Correct 1 ms 8540 KB ok
13 Correct 1 ms 6492 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8540 KB ok
2 Correct 1 ms 8540 KB ok
3 Correct 1 ms 8540 KB ok
4 Correct 1 ms 8540 KB ok
5 Correct 1 ms 8536 KB ok
6 Correct 1 ms 8540 KB ok
7 Correct 1 ms 6492 KB ok
8 Correct 1 ms 8540 KB ok
9 Correct 1 ms 8540 KB ok
10 Correct 1 ms 8540 KB ok
11 Correct 1 ms 8540 KB ok
12 Correct 1 ms 8540 KB ok
13 Correct 1 ms 8540 KB ok
14 Correct 1 ms 6492 KB ok
15 Correct 2 ms 8536 KB ok
16 Correct 1 ms 8540 KB ok
17 Correct 1 ms 8540 KB ok
18 Correct 2 ms 8540 KB ok
19 Correct 1 ms 8640 KB ok
20 Correct 1 ms 6492 KB ok
21 Correct 1 ms 6492 KB ok
22 Correct 1 ms 6492 KB ok
23 Correct 1 ms 6488 KB ok
24 Correct 1 ms 6492 KB ok
25 Correct 1 ms 6492 KB ok
26 Correct 1 ms 8640 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8540 KB ok
2 Correct 1 ms 8540 KB ok
3 Correct 1 ms 8540 KB ok
4 Correct 2 ms 6492 KB ok
5 Correct 1 ms 8540 KB ok
6 Correct 1 ms 8540 KB ok
7 Correct 1 ms 8536 KB ok
8 Correct 1 ms 8540 KB ok
9 Correct 1 ms 6492 KB ok
10 Correct 1 ms 8540 KB ok
11 Correct 1 ms 8540 KB ok
12 Correct 1 ms 8540 KB ok
13 Correct 1 ms 8540 KB ok
14 Correct 1 ms 8540 KB ok
15 Correct 1 ms 8540 KB ok
16 Correct 1 ms 6492 KB ok
17 Correct 2 ms 8536 KB ok
18 Correct 1 ms 8540 KB ok
19 Correct 1 ms 8540 KB ok
20 Correct 2 ms 8540 KB ok
21 Correct 1 ms 8640 KB ok
22 Correct 1 ms 6492 KB ok
23 Correct 1 ms 6492 KB ok
24 Correct 1 ms 6492 KB ok
25 Correct 1 ms 6488 KB ok
26 Correct 1 ms 6492 KB ok
27 Correct 1 ms 6492 KB ok
28 Correct 1 ms 8640 KB ok
29 Correct 1 ms 6492 KB ok
30 Correct 2 ms 8796 KB ok
31 Correct 2 ms 8796 KB ok
32 Correct 1 ms 8796 KB ok
33 Correct 2 ms 6744 KB ok
34 Correct 1 ms 6748 KB ok
35 Correct 1 ms 6748 KB ok
36 Correct 1 ms 6748 KB ok
37 Correct 1 ms 6748 KB ok
38 Correct 1 ms 6748 KB ok
39 Correct 1 ms 6748 KB ok
40 Correct 1 ms 8540 KB ok
41 Correct 1 ms 9048 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8540 KB ok
2 Correct 1 ms 8540 KB ok
3 Correct 1 ms 8540 KB ok
4 Correct 2 ms 6492 KB ok
5 Correct 1 ms 8540 KB ok
6 Correct 1 ms 8540 KB ok
7 Correct 1 ms 8536 KB ok
8 Correct 1 ms 8540 KB ok
9 Correct 1 ms 6492 KB ok
10 Correct 1 ms 8540 KB ok
11 Correct 1 ms 8540 KB ok
12 Correct 1 ms 8540 KB ok
13 Correct 1 ms 8540 KB ok
14 Correct 1 ms 8540 KB ok
15 Correct 1 ms 8540 KB ok
16 Correct 1 ms 6492 KB ok
17 Correct 2 ms 8536 KB ok
18 Correct 1 ms 8540 KB ok
19 Correct 1 ms 8540 KB ok
20 Correct 2 ms 8540 KB ok
21 Correct 1 ms 8640 KB ok
22 Correct 1 ms 6492 KB ok
23 Correct 1 ms 6492 KB ok
24 Correct 1 ms 6492 KB ok
25 Correct 1 ms 6488 KB ok
26 Correct 1 ms 6492 KB ok
27 Correct 1 ms 6492 KB ok
28 Correct 1 ms 8640 KB ok
29 Correct 1 ms 6492 KB ok
30 Correct 2 ms 8796 KB ok
31 Correct 2 ms 8796 KB ok
32 Correct 1 ms 8796 KB ok
33 Correct 2 ms 6744 KB ok
34 Correct 1 ms 6748 KB ok
35 Correct 1 ms 6748 KB ok
36 Correct 1 ms 6748 KB ok
37 Correct 1 ms 6748 KB ok
38 Correct 1 ms 6748 KB ok
39 Correct 1 ms 6748 KB ok
40 Correct 1 ms 8540 KB ok
41 Correct 1 ms 9048 KB ok
42 Correct 39 ms 36736 KB ok
43 Correct 35 ms 36412 KB ok
44 Correct 41 ms 37148 KB ok
45 Correct 37 ms 37264 KB ok
46 Correct 35 ms 37012 KB ok
47 Correct 28 ms 36856 KB ok
48 Correct 39 ms 29776 KB ok
49 Correct 26 ms 29776 KB ok
50 Correct 187 ms 31184 KB ok
51 Correct 30 ms 31704 KB ok
52 Correct 22 ms 27908 KB ok
53 Correct 21 ms 26960 KB ok
54 Correct 22 ms 29020 KB ok
55 Correct 26 ms 28772 KB ok
56 Correct 22 ms 31064 KB ok
57 Correct 28 ms 37208 KB ok
58 Correct 26 ms 37228 KB ok
59 Correct 27 ms 37468 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8540 KB ok
2 Correct 1 ms 8540 KB ok
3 Correct 1 ms 8540 KB ok
4 Correct 2 ms 6492 KB ok
5 Correct 1 ms 8540 KB ok
6 Correct 1 ms 8644 KB ok
7 Correct 1 ms 8540 KB ok
8 Correct 3 ms 15316 KB ok
9 Correct 28 ms 36444 KB ok
10 Correct 412 ms 167508 KB ok
11 Correct 1 ms 8540 KB ok
12 Correct 1 ms 8536 KB ok
13 Correct 1 ms 8540 KB ok
14 Correct 1 ms 6492 KB ok
15 Correct 1 ms 8540 KB ok
16 Correct 1 ms 8540 KB ok
17 Correct 1 ms 8540 KB ok
18 Correct 1 ms 8540 KB ok
19 Correct 1 ms 8540 KB ok
20 Correct 1 ms 8540 KB ok
21 Correct 1 ms 6492 KB ok
22 Correct 2 ms 8536 KB ok
23 Correct 1 ms 8540 KB ok
24 Correct 1 ms 8540 KB ok
25 Correct 2 ms 8540 KB ok
26 Correct 1 ms 8640 KB ok
27 Correct 1 ms 6492 KB ok
28 Correct 1 ms 6492 KB ok
29 Correct 1 ms 6492 KB ok
30 Correct 1 ms 6488 KB ok
31 Correct 1 ms 6492 KB ok
32 Correct 1 ms 6492 KB ok
33 Correct 1 ms 8640 KB ok
34 Correct 1 ms 6492 KB ok
35 Correct 2 ms 8796 KB ok
36 Correct 2 ms 8796 KB ok
37 Correct 1 ms 8796 KB ok
38 Correct 2 ms 6744 KB ok
39 Correct 1 ms 6748 KB ok
40 Correct 1 ms 6748 KB ok
41 Correct 1 ms 6748 KB ok
42 Correct 1 ms 6748 KB ok
43 Correct 1 ms 6748 KB ok
44 Correct 1 ms 6748 KB ok
45 Correct 1 ms 8540 KB ok
46 Correct 1 ms 9048 KB ok
47 Correct 39 ms 36736 KB ok
48 Correct 35 ms 36412 KB ok
49 Correct 41 ms 37148 KB ok
50 Correct 37 ms 37264 KB ok
51 Correct 35 ms 37012 KB ok
52 Correct 28 ms 36856 KB ok
53 Correct 39 ms 29776 KB ok
54 Correct 26 ms 29776 KB ok
55 Correct 187 ms 31184 KB ok
56 Correct 30 ms 31704 KB ok
57 Correct 22 ms 27908 KB ok
58 Correct 21 ms 26960 KB ok
59 Correct 22 ms 29020 KB ok
60 Correct 26 ms 28772 KB ok
61 Correct 22 ms 31064 KB ok
62 Correct 28 ms 37208 KB ok
63 Correct 26 ms 37228 KB ok
64 Correct 27 ms 37468 KB ok
65 Correct 763 ms 172688 KB ok
66 Correct 382 ms 146544 KB ok
67 Correct 332 ms 138928 KB ok
68 Correct 641 ms 175996 KB ok
69 Correct 1319 ms 170964 KB ok
70 Correct 1227 ms 170344 KB ok
71 Correct 623 ms 175444 KB ok
72 Correct 401 ms 167448 KB ok
73 Correct 389 ms 154708 KB ok
74 Correct 384 ms 154536 KB ok
75 Correct 377 ms 155160 KB ok
76 Execution timed out 4560 ms 155756 KB Time limit exceeded
77 Halted 0 ms 0 KB -