QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#610118 | #9417. Palindromic Polygon | Komorebie# | WA | 2ms | 7920kb | C++17 | 2.9kb | 2024-10-04 14:58:22 | 2024-10-04 14:58:47 |
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 abs(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);
if (i != last[u][a[i].f]) // 上面的一层搜索已经搜过了
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5736kb
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: 5716kb
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: 7920kb
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:
20217 15332 16971 15162 23258 25637 29725 26711 13360 17385 23893 15216 36967 23448 31182 20073 15433 18965 19121 36844 29825 21150 9256 16890 23478 25576 26600 22774 12041 13523 5462 26128 20034 37732 20386 11645 22501 22762 26363 12178 21834 37785 35411 27378 24318 22685 42710 32334 19989 9378 311...
result:
wrong answer 1st numbers differ - expected: '3857', found: '20217'