QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#609567#9417. Palindromic PolygonUESTC_NLNS#WA 2ms9972kbC++141.8kb2024-10-04 13:27:132024-10-04 13:27:18

Judging History

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

  • [2024-10-04 13:27:18]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:9972kb
  • [2024-10-04 13:27:13]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1005;
const ll INF=0x3f3f3f3f3f3f3f3f;
struct point{
	int x,y;
	ll operator ^ (const point &t) const{
		return 1ll*x*t.y-1ll*y*t.x;
	}
}p[N];
struct node{
	int l,r;
};
queue<node> q;
int T,n,cnt,f[N],L[N][N],R[N][N],P[N];
__int128 F[N][N];
ll ans;
bool vis[N][N];
unordered_map<int,int> mp; 

void BFS(int sl,int sr)
{
	for(int i=sl;i<=sr;i++) for(int j=sl+1;j<=sr;j++) F[i][j]=-INF,vis[i][j]=false;
	F[sl][sr]=p[sr]^p[sl];
	q.push({sl,sr});vis[sl][sr]=true;
	node now;int lst,l,r;
	while(!q.empty())
	{
		now=q.front();q.pop();lst=0;
		l=now.l;r=now.r;
		ans=max(ans,(ll)(F[l][r]+(p[l]^p[r])));
		for(int i=l+1;i<r;i++)
		{
			if(L[r][f[i]]<i||L[r][f[i]]<=lst) continue;
			lst=L[r][f[i]];
			F[i][lst]=max(F[i][lst],F[l][r]+(p[l]^p[i])+(p[lst]^p[r]));
			if(!vis[i][lst]) q.push({i,lst}),vis[i][lst]=true;
		}
	}
	return;
}
int g(int x)
{
	if(mp.find(x)==mp.end()) mp[x]=++cnt;
	return mp[x];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>T;
	while(T--)
	{
		cin>>n;cnt=0;ans=-INF;
		for(int i=1;i<=n;i++) cin>>f[i],f[i]=g(f[i]);
		for(int i=1;i<=n;i++) cin>>p[i].x>>p[i].y,p[n+i]=p[i];
		for(int i=1;i<=cnt;i++) P[i]=0;
		for(int i=1;i<=n*2;i++)
		{
			for(int j=1;j<=cnt;j++) L[i][j]=P[j];
			P[f[i]]=i;
		}
		for(int i=1;i<=cnt;i++) P[i]=n*2+1;
		for(int i=n*2;i>=1;i--)
		{
			for(int j=1;j<=cnt;j++) R[i][j]=P[j];
			P[f[i]]=i;
		}
		for(int i=1;i<=n;i++)
		{
			if(R[i][f[i]]>=n+i) continue;
			if(R[i][f[i]]<=n) BFS(R[i][f[i]],i+n);
			else BFS(R[i][f[i]]-n,i);
		}
		cout<<ans<<"\n";
		mp.clear();
	}
	return 0;
}
/*
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
*/

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 9736kb

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

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

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:

3713
1068
877
400
1769
2793
1165
2578
425
925
2287
512
3653
1733
2970
2051
613
1682
1083
3496
1798
1646
452
329
3151
6572
1275
3122
1332
751
142
2763
1615
6140
2008
485
1742
2028
1146
375
1005
5119
4758
902
3907
2289
4378
4459
1438
1473
2944
2044
1294
1187
2822
1991
2380
3970
3070
2224
4127
287
546
...

result:

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