【BZOJ】【P2338】【HNOI2011】【数矩形】【题解】【乱搞】

传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2338

n^2枚举对角线

记录长度和中点

矩阵的对角线长度相等,中点相同

暴力就好了

似乎有数据可以卡?

Code:

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1501;
struct point{
	LL x,y;
	point(LL _x=0,LL _y=0):x(_x),y(_y){}
	bool operator<(point oth)const{return x<oth.x||(x==oth.x&&y<oth.y);}
	bool operator==(point oth)const{return x==oth.x&&y==oth.y;};
	point operator+(point oth)const{return point(x+oth.x,y+oth.y);}
	point operator-(point oth)const{return point(x-oth.x,y-oth.y);}
	LL operator*(point oth)const{return x*oth.y-y*oth.x;}	
}a[maxn];
LL sqr(LL x){return x*x;}
struct Line{
	LL len;
	int i,j;
	point md;
	bool operator==(Line oth)const{return len==oth.len&&md==oth.md;}
	bool operator<(Line oth)const{if(len==oth.len)return md<oth.md;return len<oth.len;}
}L[maxn*maxn>>1];
int n,m;
LL LLabs(LL x){return x<0?-x:x;}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld%lld",&a[i].x,&a[i].y);
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			m++;
			L[m].i=i;L[m].j=j;
			L[m].len=sqr(a[i].x-a[j].x)+sqr(a[i].y-a[j].y);
			L[m].md=a[i]+a[j];
		}
	}sort(L+1,L+1+m);
	LL ans=0;
	for(int i=1;i<=m;i++)
	for(int j=i-1;j&&L[i]==L[j];j--)
	ans=max(ans,LLabs((a[L[i].i]-a[L[j].i])*(a[L[i].i]-a[L[j].j])));
	cout<<ans<<endl;
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值