QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#660396#9417. Palindromic PolygonLateRegistration#WA 0ms3584kbC++201.2kb2024-10-20 10:57:092024-10-20 10:57:10

Judging History

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

  • [2024-10-20 10:57:10]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3584kb
  • [2024-10-20 10:57:09]
  • 提交

answer

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

using ll = long long;

void chk_max(ll &x, ll y) {
	if (x < y) {
		x = y;
	}
}

void solve() {
	int n;
	cin >> n;
	vector<int> f(n);
	for (int &x : f) {
		cin >> x;
	}
	vector<ll> x(n), y(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	f.insert(f.end(), f.begin(), f.end());
	x.insert(x.end(), x.begin(), x.end());
	y.insert(y.end(), y.begin(), y.end());
	auto cross = [&](int i, int j) {
		return x[i] * y[j] - y[i] * x[j];
	};
	vector dp(2 * n, vector<ll>(2 * n, LLONG_MIN)), dp2(dp);
	for (int i = 0; i < 2 * n; i++) {
		dp[i][i] = 0;
	}
	ll ans = 0;
	for (int len = 0; len <= n; len++) {
		for (int l = 0, r = len; r < 2 * n; l++, r++) {
			if (dp[l][r] != LLONG_MIN) {
				chk_max(ans, dp[l][r] + cross(r, l));
				for (int i = 0; i < l; i++) {
					chk_max(dp2[i][r], dp[l][r] + cross(i, l));
				}
			}
			if (dp2[l][r] != LLONG_MIN) {
				for (int i = r + 1; i < 2 * n; i++) {
					if (f[l] == f[i]) {
						chk_max(dp[l][i], dp2[l][r] + cross(r, i));
					}
				}
			}
		}
	}
	cout << ans << "\n";
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	int T;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

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:

93
0
1

result:

wrong answer 1st numbers differ - expected: '84', found: '93'