[HNOI2011]数矩形

2338: [HNOI2011]数矩形

Time Limit: 20 Sec   Memory Limit: 128 MB
Submit: 556   Solved: 214
[ Submit][ Status]

Description

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
class Dread{
    private:
        bool isdigit(char ch) { return ch >= '0' && ch <= '9'; }
        bool isalpha(char ch) { return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'); }
        void Getchar(int &tmp){
            char ch; tmp = 0; bool b = true;
            while (ch = getchar()){
				if (ch == '-') b = false;
				if (isdigit(ch)) break;
            }
			for (; isdigit(ch); ch = getchar()) tmp = tmp * 10 + ch - '0';
        	if (!b) tmp = -tmp;
		}
        void Getchar(char &tmp){
            while (tmp = getchar()) if (isalpha(tmp)) break;
        }
    public:
        int Int(){ int x; Getchar(x); return x; }
        char Ch(){ char x; Getchar(x); return x; }
}Read;
typedef long long LL ;
struct Tpoint{
	LL x, y;
	Tpoint() {};
	Tpoint(LL _a, LL _b) : x(_a), y(_b) {};	
	Tpoint operator - (Tpoint b) { return Tpoint(x - b.x, y - b.y); }
	bool operator != (Tpoint a) { return x != a.x || y != a.y; } 

};
const LL maxn = 1510;
struct zy{
	Tpoint a;
	int b, c;
}zhong[maxn * maxn];

Tpoint point[maxn];
LL n, m;
void init(){
	n = Read.Int();
	for (LL i = 1; i <= n; i ++)
		point[i].x = Read.Int() * 2, point[i].y = Read.Int() * 2;
	for (LL i = 1; i <= n; i ++)
		for (LL j = 1; j <= n; j ++)
			if (i != j){
				zhong[++ m].a = Tpoint((point[i].x + point[j].x) / 2, (point[i].y + point[j].y) / 2);
				zhong[m].b = i;
				zhong[m].c = j;
			}
}
LL Ans = 0;
LL det(Tpoint a, Tpoint b){ return (a.x * b.y - a.y * b.x); }
LL dis(Tpoint a, Tpoint b){ return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y); }
LL cpr(Tpoint a, Tpoint b, Tpoint c){ return det(a - c, b - c); }
Tpoint ans[8];
zy aa[1500];

bool cmp(zy aa, zy bb){
	Tpoint V = bb.a;
	LL x = aa.a.x, y = aa.a.y;
	if (x != V.x) return x < V.x;
	if (y != V.y) return y < V.y;
	return (dis(point[aa.b], point[aa.c]) < dis(point[bb.b], point[bb.c]));
}
LL ab(LL x) {return x > 0 ? x : - x; }
void work(){
	sort(zhong + 1, zhong + m + 1, cmp);
	LL num = 0;
	for (int i = 2; i <= m; i ++){
		LL a = dis(point[zhong[i].b], point[zhong[i].c]);
		LL b = dis(point[zhong[i - 1].b], point[zhong[i - 1].c]);
		if (zhong[i].a != zhong[i - 1].a || a != b){
			++ num; 
			for (int j = i - num; j < i; j ++)
				for (int k = i - num; k < i; k ++)
					if (j != k)
						Ans = max(Ans, ab(cpr(point[zhong[k].b], point[zhong[k].c], point[zhong[j].b])));
			num = 0; 
		}else num ++;
	}
	cout <<Ans / 4 <<endl;
}
int main(){
	init();
	work();
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值