QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#610155 | #9417. Palindromic Polygon | durduryu | WA | 2ms | 7608kb | C++17 | 2.9kb | 2024-10-04 15:03:59 | 2024-10-04 15:03:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 3004
ll t, n, minn = 0;
long double maxx = 0;
int last[maxn][maxn], nex[maxn][maxn];
long double ans;
unordered_map<ll, int> f;
int tot = 0;
struct point
{
ll x, y, f;
} a[maxn];
ll mul(point a, point b)
{
return a.x * b.y - a.y * b.x;
}
void dfs(int v, int u, long double ans)
{
int min1 = 0, max1 = INT_MAX;
if (u == v)
{
maxx = max(abs(ans), maxx);
return;
}
else if (u == v + 1)
{
maxx = max(abs(ans + mul(a[v], a[u])), maxx);
return;
}
for (int i = v + 1; i < u; i++)
{
if (last[u][a[i].f] >= min1)
{
min1 = max(last[u][a[i].f], min1);
dfs(i, last[u][a[i].f], ans + mul(a[v], a[i]) + mul(a[last[u][a[i].f]], a[u]));
}
}
for (int i = u - 1; i >= v + 1; i--)
{
if (nex[v][a[i].f] <= max1)
{
max1 = min(nex[v][a[i].f], max1);
dfs(i, nex[v][a[i].f], ans + mul(a[v], a[nex[v][a[i].f]]) + mul(a[i], a[u]));
}
}
return;
}
void solve(int x)
{
int v = x + 1, u;
ll maxi = 0;
for (int i = n + x; i >= x + 3 && i >= minn; i--)
{
if (a[i].f == a[v].f)
{
maxi = max((ll)i, maxi);
dfs(v, i, mul(a[i], a[v]));
}
}
minn = max(minn, maxi);
return;
}
int main()
{
ios::sync_with_stdio(false);
cin >> t;
while (t--)
{
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i].f;
a[i + n].f = a[i].f;
if (!f[a[i].f])
{
f[a[i].f] = ++tot;
}
}
for (int i = 1; i <= n; i++)
{
cin >> a[i].x >> a[i].y;
a[i + n].x = a[i].x;
a[i + n].y = a[i].y;
int x = f[a[i].f];
a[i].f = a[i + n].f = x;
}
memset(last[1], 0, sizeof(last[1]));
memset(nex[2 * n - 1], 0, sizeof(nex[2 * n - 1]));
for (int i = 2; i < 2 * n; i++)
{
for (int j = 1; j <= tot; j++)
{
if (a[i - 1].f == j)
last[i][j] = i - 1;
else
last[i][j] = last[i - 1][j];
}
}
for (int i = 2 * n - 2; i >= 1; i--)
{
for (int j = 1; j <= tot; j++)
{
if (a[i + 1].f == j)
nex[i][j] = i + 1;
else
nex[i][j] = nex[i + 1][j];
}
}
for (int i = 0; i < n; i++)
{
solve(i);
}
cout << (ll)(maxx + 0.5) << endl;
maxx = 0;
minn = 0;
tot = 0;
f.clear();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5620kb
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: 5692kb
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: 2ms
memory: 7608kb
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 877 516 2668 3559 1165 3468 560 925 3502 696 3824 1746 2970 1826 613 2221 1130 4677 1900 1646 564 273 3203 6572 1070 3330 1024 765 142 3038 1615 9445 2122 320 1741 2561 1145 480 2094 5119 5458 2446 3929 2249 4378 4927 2299 1473 2944 1574 1990 1609 3367 2088 1459 2663 2617 2298 4048 215 546...
result:
wrong answer 49th numbers differ - expected: '2356', found: '2299'