萌新40pts求助
查看原帖
萌新40pts求助
523525
徐天乾楼主2022/2/11 18:27
#include<bits/stdc++.h>
#define int long long
#define O 0.114514
using namespace std;
int i,j,n,num,Max;double const eps=1e-9;
struct node{int x,y;}a[1550];struct node_{double x,y;};
struct Node{node l,r;double len,gra,inte;}A[1201250]; 
double dis(node a,node b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}
double grad(node_ a,node_ b){return (a.x-b.x)/(b.y-a.y);} 
double inter(node_ a,node_ b){return (a.x*a.x+a.y*a.y-b.x*b.x-b.y*b.y)/2/(a.y-b.y);} 
node_ rot(node a){return {a.x*cos(O)-a.y*sin(O),a.x*sin(O)+a.y*cos(O)};}
bool cmp(Node a,Node b){return (a.len<b.len)||(a.len==b.len&&a.gra<b.gra)||(a.len==b.len&&a.gra==b.gra&&a.inte<b.inte)||(a.len==b.len&&a.gra==b.gra&&a.inte==b.inte&&a.l.x+a.r.x<b.l.x+b.r.x);}
int vec(node a,node b){return a.x*b.y-a.y*b.x;}
int area(node a,node b,node c){return abs(vec({b.x-a.x,b.y-a.y},{c.x-a.x,c.y-a.y}));}
int max(int x,int y){return (x>y)?x:y;}
signed main(){ 
	scanf("%lld",&n);
	for (i=1;i<=n;i++) scanf("%lld %lld",&a[i].x,&a[i].y);
	for (i=2;i<=n;i++)
		for (j=1;j<i;j++)
			A[++num]={a[i],a[j],dis(a[i],a[j]),grad(rot(a[i]),rot(a[j])),inter(rot(a[i]),rot(a[j]))};
	sort(A+1,A+1+num,cmp);
	for (i=1;i<=num;i=j){
		for (j=i+1;j<=num;j++)
			if (fabs(A[i].len-A[j].len)>eps||fabs(A[i].gra-A[j].gra)>eps||fabs(A[i].inte-A[j].inte)>eps)
				break;
		if (i!=j-1) Max=max(Max,area(A[i].l,A[i].r,A[j-1].l));	
	}		
	printf("%lld\n",Max);
	return 0;
}                                    
2022/2/11 18:27
加载中...