QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#615452#9417. Palindromic Polygonbruteforce_WA 1ms3612kbC++201.7kb2024-10-05 18:42:572024-10-05 18:42:57

Judging History

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

  • [2024-10-05 18:42:57]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3612kb
  • [2024-10-05 18:42:57]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+7,inf=4e18,mod=998244353;
vector<array<int,2>> p;
int S(array<int,2> a,array<int,2> b)
{
	return abs(a[0]*b[1]-a[1]*b[0]);
}
struct seg
{
	int l,r,area;
	seg()
	{
		l=r=0;
		area=0;
	}
	seg(int a,int b,int c):l(a),r(b),area(c)
	{
	}
	~seg()
	{
		l=r=area=0;
	}
};
seg max(seg a,seg b)
{
	return a.area>b.area?a:b;
}
array<int,2> operator - (array<int,2> a,array<int,2> b)
{
	return {a[0]-b[0],a[1]-b[1]};
}
vector<vector<seg>> dp;
seg merge(seg a,int l,int r)
{
	array<int,2> x=p[l]-p[a.l],y=p[r]-p[a.l];
	array<int,2> z=p[a.r]-p[a.l];
	return seg(l,r,a.area+S(z,y)+S(y,x));
}
void O_o()
{
	int n;
	cin>>n;
	dp=vector<vector<seg>> (2*n+1,vector<seg>(2*n+1));
	vector<int> a(n+1);
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
		a.push_back(a[i]);
	}
	p.assign(n+1,{0,0});
	for(int i=1; i<=n; i++)
	{
		cin>>p[i][0]>>p[i][1];
		p.push_back(p[i]);
	}
	for(int i=1; i<=2*n; i++)
	{
		dp[i][i]=seg(i,i,0);
		if(i<2*n&&a[i]==a[i+1])
			dp[i][i+1]=seg(i,i+1,0);
	}
	for(int len=3; len<=n; len++)
	{
		for(int l=1; l<=2*n-len+1; l++)
		{
			int r=l+len-1;
			dp[l][r]=max(dp[l][r-1],dp[l+1][r]);
			dp[l][r]=max(dp[l+1][r-1],dp[l][r]);
			if(a[l]==a[r])
			{
				//fix l+1
				for(int k=l+1; k<=r-1; k++)
				{
					dp[l][r]=max(dp[l][r],merge(dp[l+1][k],l,r));
					dp[l][r]=max(dp[l][r],merge(dp[k][r-1],l,r));
				}
			}
		}
	}
	seg ans=seg();
	ans.area=0;
	for(int i=1; i<=n; i++)
		ans=max(ans,dp[i][i+n-1]);
	cout<<ans.area<<"\n";
}
signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout<<fixed<<setprecision(12);
	int T=1;
	cin>>T;
	while(T--)
	{
		O_o();
	}
}
















Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3568kb

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

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

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:

10363
4948
5595
4506
12215
11338
4880
11711
2675
4665
10541
7602
16648
8259
14104
9379
1678
10582
8749
15895
12703
9800
3636
3160
13255
13726
10196
12228
6002
6474
1520
13932
8514
11872
11098
4925
8594
8540
13162
2373
11455
19950
16780
2446
13339
11842
20146
16766
10411
3520
15607
7600
14412
4414
10...

result:

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