什么??!怎么又是计算几何,您钛毒瘤了……
这道题真的是毒瘤
凸包?旋转卡壳?
看一下数据,N<=1500?
暴力
没错,就是暴力,N^2没毛病
枚举任意两个点,计算距离和连成线段的中点,这些线段作为矩形的对角线
矩形对角线长度相等,互相平分
所以……给线段排序
cmp先按线段长度排序,再按中点坐标排序
最后暴力统计
end
上代码
记得要用long long
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
#define N 1500
using namespace std;
inline ll read(){
ll f=1,x=0;char ch;
do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
return f*x;
}
inline ll Max(register ll a,register ll b)
{
return a>b?a:b;
}
struct node
{
ll x,y;
ll operator ^ (const node& rhs) const
{
return x*rhs.y-y*rhs.x;
}
node operator - (const node& rhs) const
{
return (node){x-rhs.x,y-rhs.y};
}
node operator + (const node& rhs) const
{
return (node){x+rhs.x,y+rhs.y};
}
}a[N+5];
struct line
{
node li,mi;
ll l;
}p[N*N+5];
inline bool cmp(register line aa,register line bb)
{
return aa.l==bb.l? aa.mi.x==bb.mi.x?aa.mi.y<bb.mi.y:aa.mi.x<bb.mi.x :aa.l>bb.l;
}
int n,m;
inline ll dis(register int i,register int j)
{
return (a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y);
}
int main()
{
n=read();
for(register int i=1;i<=n;++i)
{
a[i].x=read(),a[i].y=read();
for(register int j=1;j<i;++j)
{
p[++m].li=a[i]-a[j];
p[m].mi=a[i]+a[j];
p[m].l=dis(i,j);
}
}
sort(p+1,p+m+1,cmp);
ll ans=0;
for(register int i=1,j=1;i<=m;i=j)
{
while(p[j].l==p[i].l&&p[j].mi.x==p[i].mi.x&&p[j].mi.y==p[i].mi.y)
++j;
for(register int k=i;k<j;++k)
for(register int l=k+1;l<j;++l)
ans=Max(ans,(abs(p[k].li^p[l].li))>>1);
}
printf("%lld",ans);
return 0;
}