[暴力 乱搞] BZOJ 2338 [HNOI2011]数矩形

枚举对角线,两条对角线合法必定中点重合 长度相同

暴力两辆计算竟然没T


#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long ll;

inline char nc()
{
	static char buf[100000],*p1=buf,*p2=buf;
	if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
	return *p1++;
}

inline void read(int &x){
	char c=nc(),b=1;
	for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
	for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}

inline void read(ll &x){
	char c=nc(),b=1;
	for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
	for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}

struct Point{
	ll x,y;
	Point(ll x=0,ll y=0):x(x),y(y) { }
	void read(){
		::read(x); ::read(y);
	}	
	friend bool operator < (const Point &A,const Point &B) {
		return A.x==B.x?A.y<B.y:A.x<B.x;
	}
	friend bool operator == (const Point &A,const Point &B) {
		return A.x==B.x && A.y==B.y;
	}
	friend Point operator + (const Point A,const Point B) {
		return Point(A.x+B.x,A.y+B.y);
	}
	friend Point operator - (const Point A,const Point B) {
		return Point(A.x-B.x,A.y-B.y);
	}
	friend ll operator * (const Point A,const Point B) {
		return A.x*B.y-B.x*A.y;
	}
	friend ll Dist(Point A,Point B){
		return (A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y);
	}
	friend ll Cross(Point p1,Point p2,Point p0){
		return (p1-p0)*(p2-p0);
//		return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
	}
}P[1505];

struct Line{
	Point M;
	ll Len;
	int x,y;
	Line(){
	}
	Line(int ix,int iy){
		x=ix; y=iy;
		M=P[x]+P[y];
		Len=Dist(P[x],P[y]);
	}
	bool operator < (const Line &B) const{
		return Len==B.Len?M<B.M:Len<B.Len;
	}
}L[2250005];

int n,cnt;
ll ans;

inline ll Area(int a,int b){
	return abs(Cross(P[L[a].x],P[L[b].y],P[L[b].x]));
}

int main()
{
	freopen("t.in","r",stdin);
	freopen("t.out","w",stdout);
	read(n);
	for (int i=1;i<=n;i++)
		P[i].read();
	sort(P+1,P+n+1);
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++)
			L[++cnt]=Line(i,j);
	sort(L+1,L+cnt+1);
	for (int i=1;i<=cnt;i++)
		for (int j=i+1;j<=cnt && L[i].M==L[j].M && L[i].Len==L[j].Len;j++)
			ans=max(ans,Area(i,j));
	printf("%lld\n",ans);
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值