QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#609584 | #9417. Palindromic Polygon | UESTC_xxx# | WA | 1ms | 6032kb | C++20 | 1.6kb | 2024-10-04 13:29:23 | 2024-10-04 13:29:26 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>
#include<map>
#define ll long long
using namespace std;
int tt,n,v[2005];
struct node{
ll x,y;
}p[500005];
ll f[1005][1005][3];
node ms(node a,node b){
node c;
c.x=a.x-b.x,c.y=a.y-b.y;
return c;
}
ll cross(node a,node b){
return abs(a.x*b.y-a.y*b.x);
}
ll area(int p1,int p2,int p3){
p1=(p1-1)%n+1;
p2=(p2-1)%n+1;
p3=(p3-1)%n+1;
return cross(ms(p[p1],p[p2]),ms(p[p1],p[p3]));
}
int id(int i){
return i=(i-1)%n+1;
}
int main(){
scanf("%d",&tt);
while(tt--){
scanf("%d",&n);
for(int i=1;i<=n;++i) scanf("%d",&v[i]),v[i+n]=v[i];
for(int i=1;i<=n;++i){
scanf("%lld%lld",&p[i].x,&p[i].y);
}
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j) f[i][j][0]=f[i][j][1]=f[i][j][2]=-1;
for(int l=n-1;l>=1;--l){
for(int i=1;i<=n;++i){
int j=i+l;
if(v[i]==v[j]) f[i][id(j)][0]=max(f[i][id(j)][0],0LL);
for(int k=i+1;k<j;++k){
if(f[i][id(j)][0]!=-1) f[id(k)][id(j)][1]=max(f[id(k)][id(j)][1],f[i][id(k)][0]+area(i,j,k));
if(f[i][id(j)][0]!=-1) f[i][id(k)][2]=max(f[i][id(k)][2],f[i][id(j)][0]+area(i,j,k));
if(f[i][id(j)][1]!=-1&&v[k]==v[i]) f[i][id(k)][0]=max(f[i][id(k)][0],f[i][id(j)][1]+area(i,j,k));
if(f[i][id(j)][2]!=-1&&v[k]==v[j]) f[id(k)][id(j)][0]=max(f[id(k)][id(j)][0],f[i][id(j)][2]+area(i,j,k));
}
}
}
ll ans=0;
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j){
ans=max(ans,f[i][j][0]);
ans=max(ans,f[i][j][1]);
ans=max(ans,f[i][j][2]);
}
printf("%lld\n",ans);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 6032kb
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: 5952kb
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: 5952kb
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:
3927 1068 877 516 2998 3559 1165 4683 560 925 4393 696 3824 1746 3668 1826 613 2221 1521 4977 1900 1646 564 273 3203 6572 1070 3364 1024 765 142 3869 1922 9445 2122 320 1741 2641 1145 480 2094 5549 6393 2446 3929 2249 4378 4927 2755 1473 3152 1574 1990 1609 3367 2298 1459 2663 2617 3107 5330 215 546...
result:
wrong answer 1st numbers differ - expected: '3857', found: '3927'