QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#609350#9417. Palindromic PolygonUESTC_xxx#WA 2ms8008kbC++201.5kb2024-10-04 12:23:402024-10-04 12:23:42

Judging History

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

  • [2024-10-04 12:23:42]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8008kb
  • [2024-10-04 12:23:40]
  • 提交

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,a[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 main(){
	scanf("%d",&tt);
	while(tt--){
		scanf("%d",&n);
		for(int i=1;i<=n;++i) scanf("%d",&a[i]),a[i+n]=a[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=i+n-1;j>=i;--j) f[i][j][0]=f[i][j][1]=f[i][j][2]=-1;
		for(int i=1;i<=n;++i){
			for(int j=i+n-1;j>=1;--j){
				if(a[i]==a[j]) f[i][j][0]=max(f[i][j][0],0LL);
				for(int k=i+1;k<j;++k){
					if(f[i][j][0]!=-1) f[k][j][1]=max(f[k][j][1],f[i][j][0]+area(i,j,k));
					if(f[i][j][0]!=-1) f[i][k][2]=max(f[i][k][1],f[i][j][0]+area(i,j,k));
					if(f[i][j][1]!=-1&&a[k]==a[i]) f[i][k][0]=max(f[i][k][0],f[i][j][1]+area(i,j,k));
					if(f[i][j][2]!=-1&&a[k]==a[j]) f[k][j][0]=max(f[k][j][1],f[i][j][2]+area(i,j,k));
				}
			}
		}
		ll ans=0;
		for(int i=1;i<=n;++i)
			for(int j=i+n-1;j>=i;--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: 5980kb

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: 5876kb

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: 8008kb

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:

4074
1068
877
516
2500
3559
1165
3637
560
925
3502
696
3653
1746
2970
2051
613
1682
1083
4677
1900
1646
564
273
3151
6915
1070
3378
1024
765
142
3038
1883
9445
2058
320
1741
2561
1484
480
2094
5119
5491
1590
3929
2249
4378
4927
2356
1473
3158
1574
2180
1609
2747
2298
1391
2663
2617
2298
4048
215
420...

result:

wrong answer 1st numbers differ - expected: '3857', found: '4074'