QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#596627#9417. Palindromic Polygonucup-team5075#WA 0ms5680kbC++142.4kb2024-09-28 16:08:422024-09-28 16:08:43

Judging History

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

  • [2024-09-28 16:08:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5680kb
  • [2024-09-28 16:08:42]
  • 提交

answer

//Linkwish's code
#include<bits/stdc++.h>
#define endl '\n'
#define si inline
#define fi first
#define se second
using namespace std;
typedef long long ll;typedef __int128 li;
typedef pair<int,int> pii;typedef pair<ll,ll> pll;
typedef const int ci;typedef const ll cl;ci iinf=INT_MAX;cl linf=1e18;
template<typename T>si bool gmax(T &x,const T y){if(x<y)return x=y,1;return 0;}
template<typename T>si bool gmin(T &x,const T y){if(y<x)return x=y,1;return 0;}

namespace LinkWish{
	
	ci N=505;

	int n,v[N];

	struct point{
		ll x,y;
	//	inline void print(){printf("(%.3lf,%.3lf)\n",x,y);}
		point operator +(const point &t)const{return (point){x+t.x,y+t.y};}
		point operator -(const point &t)const{return (point){x-t.x,y-t.y};}
		point operator *(const ll &t)const{return (point){x*t,y*t};}
		point operator /(const ll &t)const{return (point){x/t,y/t};}
		ll operator |(const point &t)const{return x*t.x+y*t.y;}
		ll operator &(const point &t)const{return x*t.y-y*t.x;}
	};
	inline ll dis(point x,point y){return (x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y);}
	struct line{
		point x,y;
		inline line(){}
		inline line(point xx,point yy){x=xx,y=yy;}
		inline ll len(){return dis(x,y);}
	};
	si ll S(point x,point y,point z){
		if(x.x>y.x)swap(x,y);
		if(y.x>z.x)swap(y,z);
		if(x.x>y.x)swap(x,y);
		return abs((y.x-x.x)*(z.y-x.y)-(z.x-x.x)*(y.y-x.y));
	}

	ll f[N][N][3];
	point a[N];

	si void solve(){
		cin>>n;
		for(int i=0;i<n;i++)cin>>v[i];
		for(int i=0;i<n;i++)cin>>a[i].x>>a[i].y;

		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				f[i][j][0]=f[i][j][1]=f[i][j][2]=-linf;

		for(int i=1;i<=n;i++)f[i][i][0]=f[i][i][1]=f[i][i][2]=0;

		ll ans=0;
		for(int len=2;len<=n;len++){
			for(int i=0,j=len-1;i<n;i++,j++){
				if(j>=n)j-=n;
				for(int c=0;c<len;c++){
					int k=(i+c)%n;
					ll s=S(a[i],a[k],a[j]);
					if(k!=i){
						gmax(f[i][j][1],f[k][j][0]+s);
						if(v[i]==v[j])gmax(f[i][j][0],f[k][j][2]+s);
					}
					if(k!=j){
						gmax(f[i][j][2],f[i][k][0]+s);
						if(v[i]==v[j])gmax(f[i][j][0],f[i][k][1]+s);
					}
				}
				gmax(ans,f[i][j][0]);
			}
		}

		cout<<ans<<endl;
	}
	si void mian(){
		int TT;cin>>TT;while(TT--)solve();
	}
}

signed main(){
	#ifndef ONLINE_JUDGE
	assert(freopen("in.in","r",stdin));
	// assert(freopen("out.out","w",stdout));
	assert(freopen("out.err","w",stderr));
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);   
	LinkWish::mian();
	return 0;
}

詳細信息

Test #1:

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

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

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: 0ms
memory: 5680kb

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
806
877
516
2668
3559
1165
3468
560
925
3502
696
3824
1746
2970
1826
613
2221
1130
4671
1867
1646
564
273
3203
6572
1070
3330
1024
765
142
3038
1615
9445
2122
320
1741
2561
1145
480
2094
5119
5214
2446
3929
2249
4378
4927
2299
1473
2944
1574
1990
1609
3367
2298
1459
2663
2617
2254
4048
166
546
...

result:

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