思路:

  1. 枚举3个点,计算第4个点并判断是否存在,复杂度为O(N3logN)或O(N3α)
  2. 考虑矩形的对角线,两条对角线可以构成一个矩形,它们的长度和中点必须完全一样,于是将所有线段按长度和中点排序,那么所有可能构成矩形的线段(对角线)一定在连续的区间内,顺序枚举即可,复杂度O(N2logN)。

  1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#pragma comment(linker, "/STACK:10240000")
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; #define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define fillchar(a, x) memset(a, x, sizeof(a))
#define copy(a, b) memcpy(a, b, sizeof(a)) typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull; #ifndef ONLINE_JUDGE
void RI(vector<int>&a,int n){a.resize(n);for(int i=;i<n;i++)scanf("%d",&a[i]);}
void RI(){}void RI(int&X){scanf("%d",&X);}template<typename...R>
void RI(int&f,R&...r){RI(f);RI(r...);}void RI(int*p,int*q){int d=p<q?:-;
while(p!=q){scanf("%d",p);p+=d;}}void print(){cout<<endl;}template<typename T>
void print(const T t){cout<<t<<endl;}template<typename F,typename...R>
void print(const F f,const R...r){cout<<f<<", ";print(r...);}template<typename T>
void print(T*p, T*q){int d=p<q?:-;while(p!=q){cout<<*p<<", ";p+=d;}cout<<endl;}
#endif
template<typename T>bool umax(T&a, const T&b){return b<=a?false:(a=b,true);}
template<typename T>bool umin(T&a, const T&b){return b>=a?false:(a=b,true);} const double PI = acos(-1.0);
const int INF = 1e9 + ;
const double EPS = 1e-12; /* -------------------------------------------------------------------------------- */ const int maxn = 1e2 + ; struct Point {
int x, y;
Point(int x, int y) {
this->x = x;
this->y = y;
}
Point operator + (const Point &that) const {
return Point(x + that.x, y + that.y);
}
Point operator - (const Point &that) const {
return Point(x - that.x, y - that.y);
}
inline ll sqr(ll a) {
return a * a;
}
ll dist(const Point &that) {
return sqr(x - that.x) + sqr(y - that.y);
}
bool operator < (const Point &that) const {
return x == that.x? y < that.y : x < that.x;
}
bool operator == (const Point &that) const {
return x == that.x && y == that.y;
}
Point() {}
}; struct Line {
Point a, b, mid;
ll len;
Line(Point a, Point b) {
this->a = a;
this->b = b;
mid = a + b;
len = a.dist(b);
}
Line() {}
bool operator < (const Line &that) const {
return len == that.len? mid < that.mid : len < that.len;
}
};
vector<Line> line;
Point p[maxn]; bool equal(const Line &a, const Line &b) {
return a.len == b.len && a.mid == b.mid;
} ll cross(Point a, Point b) {
return (ll)a.x * b.y - (ll)a.y * b.x;
} ll Area(const Line &a, Line &b) {
return abs(cross(a.a - a.b, b.a - b.b) / );
} int main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // ONLINE_JUDGE
int n;
while (cin >> n) {
for (int i = ; i < n; i ++) {
scanf("%d%d", &p[i].x, &p[i].y);
}
line.clear();
for (int i = ; i < n; i ++) {
for (int j = i + ; j < n; j ++) {
line.pb(Line(p[i], p[j]));
}
}
sort(all(line));
ll area = - ;
for (int i = ; i < line.size(); i ++) {
for (int j = i - ; j >= && equal(line[i], line[j]); j --) {
umax(area, Area(line[i], line[j]));
}
}
if (area < ) puts("No Eyes");
else cout << area << ".0000" << endl;
}
return ;
}

{bzoj2338 [HNOI2011]数矩形 && NBUT 1453 LeBlanc}平面内找最大矩形的更多相关文章

  1. bzoj2338[HNOI2011]数矩形 计算几何

    2338: [HNOI2011]数矩形 Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 1535  Solved: 693[Submit][Status ...

  2. BZOJ2338: [HNOI2011]数矩形

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2338 中学数学老师告诉我们,一个矩形的两条对角线相等,所以只要把所有的边拿出来,记录下中点坐标 ...

  3. 【计算几何】bzoj2338 [HNOI2011]数矩形

    对于两条线段,若其中点重合,且长度相等,那么它们一定是某个矩形的对角线. N*N地处理出所有线段,排序,对每一部分中点重合.长度相等的线段进行暴力枚举,更新答案. 用 long double 注意EP ...

  4. 【BZOJ2338】[HNOI2011]数矩形 几何

    [BZOJ2338][HNOI2011]数矩形 题解:比较直观的做法就是枚举对角线,两个对角线能构成矩形当且仅当它们的长度和中点相同,然后用到结论:n个点构成的矩形不超过n^2.5个(不会证),所以两 ...

  5. bzoj-2338 2338: [HNOI2011]数矩形(计算几何)

    题目链接: 2338: [HNOI2011]数矩形 Time Limit: 20 Sec  Memory Limit: 128 MB Description Input   Output 题意: 思路 ...

  6. 【题解】Luogu P3217 [HNOI2011]数矩形

    原题链接:P3217 [HNOI2011]数矩形 什么??!怎么又是计算几何,您钛毒瘤了-- 这道题真的是毒瘤 凸包?旋转卡壳? 看一下数据,N<=1500? 暴力 没错,就是暴力,N^2没毛病 ...

  7. 平面内,线与线 两条线找交点 两条线段的位置关系(相交)判定与交点求解 C#

    个人亲自编写.测试,可以正常使用   道理看原文,这里不多说   网上找到的几篇基本都不能用的   C#代码 bool Equal(float f1, float f2) { return (Math ...

  8. 【C语言】给一组组数,仅仅有两个数仅仅出现了一次,其它全部数都是成对出现的,找出这两个数。

    //给⼀组组数,仅仅有两个数仅仅出现了一次.其它全部数都是成对出现的,找出这两个数. #include <stdio.h> int find_one_pos(int num) //找一个为 ...

  9. poj 1106(半圆围绕圆心旋转能够覆盖平面内最多的点)

    Transmitters Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4955   Accepted: 2624 Desc ...

随机推荐

  1. 使用HTMLTestRunner生成报告

    使用HTMLTestRunner生成报告 unittest本身并不具备这个功能,需要使用HTMLTestRunner库 使用步骤: 首先需要下载.py文件:http://tungwaiyip.info ...

  2. NGINX 类漏洞 整理记录

    简单介绍NGINX: Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行. 其特点是占有内存少,并发能力强,nginx的并 ...

  3. [YII2] 增删改查2

    一.新增 使用model::save()操作进行新增数据 $user= new User; $user->username =$username; $user->password =$pa ...

  4. 解决IE升级后必须以管理员运行的问题

    很多网友可能都遇到过这样的问题,在ie升级后,无法打开,必须以管理员身份运行.今天我也遇到了这个问题.最终找到了解决办法. 1.Win + R 2.输入 regedit,定位到 HKEY_CURREN ...

  5. Docker 安装 Jenkins , 并解决初始安装插件失败

    安装 Jenkins 后,初始化下载插件总是失败,导致安装不成功,重试好几次都是卡在安装插件那. 这里记录下 Docker 下怎么安装 Jenkins ,并解决初始安装插件失败问题. 安装插件失败,其 ...

  6. 从头学pytorch(十三):使用GPU做计算

    GPU计算 默认情况下,pytorch将数据保存在内存,而不是显存. 查看显卡信息 nvidia-smi 我的机器输出如下: Fri Jan 3 16:20:51 2020 +------------ ...

  7. Python初学者常见错误问题汇总

    1.在客户端和服务端如何传递数组? 答:在客户端和服务端可以使用json进行数据传输.在客户端把数据转换成json字符串,然后使用POST方法发送给服务端. 服务端收集到数据之后,使用json.loa ...

  8. sort()实现排序的原理

    很多人都只知道sort()是通过快速排序实现,但它并不只是简单的快排:首先它对普通的快速排序进行了优化:此外,它还结合了插入 排序和堆排序.系统根据数据形式和数据量,来选择合适的排序方法,这并不是说每 ...

  9. memcache的缓存原理和应用

    缓存原理 Memcache采用键值对存储方式.它本质是一个大的 hash表,key的最大长度为255个字符,最长过期时间为30天.它的内存模型如下:Memcache预先将可支配的内存空间进行分区(Sl ...

  10. 闲聊http1.1的6个方法

    GET :获取资源GET 方法用来请求访问已被 URI 识别的资源.指定的资源经服务器端解析后返回响应内容. POST :传输实体主体POST 方法用来传输实体的主体.虽然用 GET 方法也可以传输实 ...