QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#597200 | #9417. Palindromic Polygon | ucup-team4474# | WA | 1ms | 5840kb | C++20 | 2.1kb | 2024-09-28 17:16:52 | 2024-09-28 17:16:53 |
Judging History
answer
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
const int N = 1e3 + 5;
using point = pair<int, int>;
point a[N];
int n, m, f[N], g[N], nxt[N][N];
long long ans, dp[N][N];
vector<int> node[N];
point vec(point a, point b)
{
point res;
res.first = b.first - a.first;
res.second = b.second - a.second;
return res;
}
long long cross(point a, point b)
{
long long ret = 1ll * a.first * b.second -
1ll * a.second * b.first;
return abs(ret);
}
void solve()
{
cin >> n;
for (int i = 1; i <= n; i++) cin >> f[i], g[i] = f[i];
for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second, a[i + n] = a[i];
sort(g + 1, g + n + 1);
m = unique(g + 1, g + n + 1) - g - 1;
for (int i = 1; i <= n; i++)
f[i] = f[i + n] = lower_bound(g + 1, g + m + 1, f[i]) - g;
for (int i = 1; i <= n * 2; i++) node[f[i]].push_back(i);
for (int i = 1; i <= m; i++)
{
nxt[i][n * 2 + 1] = n * 2 + 1;
for (int j = n * 2; j >= 1; j--)
{
if (f[j] == i) nxt[i][j] = j;
else nxt[i][j] = nxt[i][j + 1];
}
}
for (int i = 1; i <= n * 2; i++)
for (int j = i + 1; j <= n * 2; j++)
dp[i][j] = -1e18;
for (int i = 1; i < n * 2; i++)
if (f[i] == f[i + 1])
dp[i][i + 1] = 0;
ans = 0;
for (int r = 1; r <= n * 2; r++)
{
for (int l = r; l >= 1 and l > r - n; l--)
{
if (dp[l][r] < 0) continue;
ans = max(ans, dp[l][r]);
for (int x = l - 1; x >= 1 and x > r - n; x--)
for (int c = 1, y = nxt[f[x]][r + 1]; c <= 16 and y < x + n; c += 1, y = nxt[f[x]][y + 1])
dp[x][y] = max(dp[x][y], cross(vec(a[x], a[y]), vec(a[x], a[l])) + cross(vec(a[y], a[r]), vec(a[l], a[r])) + dp[l][r]);
}
}
cout << ans << '\n';
for (int i = 1; i <= m; i++) node[i].clear();
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) solve();
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5648kb
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: 0ms
memory: 5712kb
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: 0ms
memory: 5840kb
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:
3857 1068 3573 516 6241 6887 1165 6418 3573 3573 5981 696 6510 4613 4341 5083 3573 4192 4189 6160 5408 5155 3573 273 6168 8234 8454 10720 7462 7462 142 9876 7954 11965 9522 320 7896 9828 8607 7692 9451 11243 12421 7735 11446 9210 10635 12089 9680 7560 9821 8997 8688 8369 10264 9355 8166 9321 10156 9...
result:
wrong answer 3rd numbers differ - expected: '877', found: '3573'