QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#610497#9417. Palindromic PolygontreasuresgcWA 1ms3716kbC++231.4kb2024-10-04 16:14:222024-10-04 16:14:22

Judging History

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

  • [2024-10-04 16:14:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3716kb
  • [2024-10-04 16:14:22]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	int sum=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f*=-1;ch=getchar();}
	while(isdigit(ch)){sum=sum*10+ch-48;ch=getchar();}
	return sum*f;
}
int f[1005];
int dp[1005][1005];
int x[1005],y[1005];
vector<int> V[505];
map<int,int> mp;
inline int cvec(int a,int b)
{
	return (x[a]+x[b])*(y[b]-y[a]);
}
inline void calc(int L,int R,int l,int r)
{
	dp[L][R]=max(dp[L][R],dp[l][r]+cvec(L,l)+cvec(r,R));
}
inline void solve()
{
	mp.clear();
	int n;
	n=read();
	for(int i=1;i<=n;i++) f[i]=read();
	
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(mp.count(f[i])) f[i]=mp[f[i]];
		else
		{
			mp[f[i]]=++cnt;
			f[i]=cnt;
		}
	}
	
	for(int i=1;i<=n;i++) x[i]=read(),y[i]=read();
	for(int i=n+1;i<=n*2;i++) f[i]=f[i-n],x[i]=x[i-n],y[i]=y[i-n];
	int ans=0;
	for(int len=1;len<=n;len++)
		for(int l=1;l<=n;l++)
		{
			int r=l+len-1;
			
			if(f[l]!=f[r]) continue;
			dp[l][r]=cvec(l,r);
			
			for(int k=l+1;k<r;k++)V[f[k]].push_back(k);
			for(int g=1;g<=cnt;g++)
			{
				if(V[g].size()==0) continue;
				for(int j=0;j<V[g].size();j++) calc(l,r,V[g][0],V[g][j]);
				for(int j=1;j<V[g].size();j++) calc(l,r,V[g][j],V[g].back());
			}
			for(int g=1;g<=cnt;g++) V[g].clear();
			
			ans=max(ans,dp[l][r]+cvec(r,l));
		}
	cout<<ans<<endl;
}
signed main()
{
	int T;
	T=read();
	while(T--) solve(); 
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3660kb

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

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

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
6191
877
516
2496
3559
1165
3468
560
4275
15301
696
3653
1746
4047
1826
613
2632
11760
5840
30492
1646
564
273
12639
14255
1070
3122
1024
765
142
3038
1615
9445
2026
320
1741
7033
1145
5773
2094
14254
11746
1590
22020
2249
5641
8687
8146
5058
3152
1574
1990
2118
8496
3934
5419
2663
2617
12138
6...

result:

wrong answer 2nd numbers differ - expected: '1068', found: '6191'