QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#598042#9417. Palindromic Polygonucup-team5062#WA 1ms5872kbC++202.1kb2024-09-28 20:11:512024-09-28 20:11:51

Judging History

你现在查看的是最新测评结果

  • [2024-09-28 20:11:51]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5872kb
  • [2024-09-28 20:11:51]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

long long dp1[509][509];
long long dp2[509][509];

long long Solve(int N, vector<long long> V, vector<long long> X, vector<long long> Y) {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) dp1[i][j] = -(1LL << 60);
		for (int j = 0; j < N; j++) dp2[i][j] = -(1LL << 60);
	}
	for (int i = 0; i < N; i++) dp1[i][i] = 0;

	// Get Answer
	for (int haba = 0; haba < N; haba++) {
		for (int l = 0; l < N; l++) {
			int r = (l + haba) % N;

			// Step 1
			for (int more = 1; more < N - haba; more++) {
				int next_l = l - more; if (next_l < 0) next_l += N;
				// if (next_l == 4 && l == 5) cout << (X[next_l] - X[l]) * (Y[next_l] + Y[l]) << endl;
				dp2[next_l][r] = max(dp2[next_l][r], dp1[l][r] + (X[next_l] - X[l]) * (Y[next_l] + Y[l]));
			}

			// Step 2
			for (int more = 1; more < N - haba; more++) {
				int next_r = r + more; if (next_r >= N) next_r -= N;
				if (V[l] != V[next_r]) continue;
				// if (next_r == 7 && r == 5) cout << l << " " << r << " " << (X[r] - X[next_r]) * (Y[r] + Y[next_r]) << " " << dp2[l][r] << endl;
				dp1[l][next_r] = max(dp1[l][next_r], dp2[l][r] + (X[r] - X[next_r]) * (Y[r] + Y[next_r]));
			}
		}
	}
	/*for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) printf("% 4lld", max(-99LL, dp1[i][j]));
		printf("\n");
	}*/

	// Get Maximum
	long long Answer = 0;
	for (int haba = 0; haba < N; haba++) {
		for (int l = 0; l < N; l++) {
			int r = (l + haba) % N;
			long long ret = (X[r] - X[l]) * (Y[r] - Y[l]);

			// Brute Force
			for (int i = 1; i < N - haba; i++) {
				int m = (r + i) % N;
				long long r1 = (X[m] - X[l]) * (Y[m] - Y[l]);
				long long r2 = (X[r] - X[m]) * (Y[r] - Y[m]);
				ret = max(ret, r1 + r2);
			}
			Answer = max(Answer, ret + dp1[l][r]);
		}
	}

	// Return
	return Answer;
}

int main() {
	int T; cin >> T;
	for (int t = 1; t <= T; t++) {
		int N; cin >> N;
		vector<long long> V(N, 0);
		vector<long long> X(N, 0);
		vector<long long> Y(N, 0);
		for (int i = 0; i < N; i++) cin >> V[i];
		for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
		cout << Solve(N, V, X, Y) << endl;
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 5872kb

input:

3
8
2 4 2 4 3 4 5 3
2 3
0 6
-3 3
-3 0
-2 -3
1 -5
3 -3
4 0
3
1 2 3
0 0
1 0
0 1
3
1 1 1
0 0
1 0
0 1

output:

84
0
1

result:

ok 3 number(s): "84 0 1"

Test #2:

score: 0
Accepted
time: 1ms
memory: 5644kb

input:

1
4
1000000000 1000000000 1000000000 1000000000
-1000000000 -1000000000
1000000000 -1000000000
1000000000 1000000000
-1000000000 1000000000

output:

8000000000000000000

result:

ok 1 number(s): "8000000000000000000"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3620kb

input:

129
10
604040473 604040473 287094217 682965575 70435786 287094217 604040473 287094217 682965575 92620053
-193 -184
-200 -200
-125 -169
-120 -157
-120 -145
-124 -139
-137 -136
-155 -149
-172 -163
-187 -177
5
346787871 346787871 113397429 113397429 346787871
-173 -181
-186 -166
-200 -195
-194 -200
-17...

output:

28578
4903
10849
9928
21619
11489
266
23130
8869
3565
20288
13170
15218
11589
21264
16239
2817
20367
9686
21624
9547
11195
11812
5723
16775
29319
14760
14440
10457
9277
3334
16473
6160
33717
9458
13965
14776
15149
23285
3790
4757
23313
31516
11940
12177
17218
19176
20207
17289
11788
19242
11974
2221...

result:

wrong answer 1st numbers differ - expected: '3857', found: '28578'