思路:

  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. [WEB前置技能]HTTP协议

    HTTP概述 HTTP协议是Hyper Text Transfer Protocol(超文本传输协议)的缩写,是用于从万维网(WWW:World Wide Web )服务器传输超文本到本地浏览器的传送 ...

  2. 云开发静态网站托管现已支持 Angular 应用

    云开发静态托管是云开发提供的静态网站托管的能力,静态资源(HTML.CSS.JavaScript.字体等)的分发由腾讯云对象存储 COS 和拥有多个边缘网点的腾讯云 CDN 提供支持. 在云开发静态托 ...

  3. python 基础篇 匿名函数

    匿名函数基础 首先,什么是匿名函数呢?以下是匿名函数的格式: lambda argument1, argument2,... argumentN : expression 我们可以看到,匿名函数的关键 ...

  4. Java标识符中常见的命名规则

    标识符:就是给类,接口,方法,变量等起名字.组成规则:A:英文字母大小写B:数字字符C:$和_注意事项:A:不能以数字开头B:不能使Java中的关键字C:Java语言严格区分大小写常见的命名规则:见名 ...

  5. 牛客网机试题-求root(N,k)

    题目描述     N<k时,root(N,k) = N,否则,root(N,k) = root(N',k).N'为N的k进制表示的各位数字之和.输入x,y,k,输出root(x^y,k)的值 ( ...

  6. thinkphp if便签的使用

    <foreach name="list" item='v'> <tr> <td><img class="user" s ...

  7. 2019-2020-1 20199328《Linux内核原理与分析》第九周作业

    笔记部分 2019/11/12 14:45:44 从CPU和内存的角度看linux系统的运行 CPU角度:首先我们进行了系统调度,然后系统进入内核态,把信息压栈,然后我们进行进程管理,由于进入系统调用 ...

  8. Shodan使用简述

    申明 本文只做相关介绍,使用者应当严格自律,承诺遵守法律法规     Shodan,一款互联网下的可怕搜索引擎.它的可怕之处在于Shodan可以搜索各种在线的网络设备.比如:摄像头.路由器.打印机.服 ...

  9. 还在写CURD?试试这款基于mybatis-plus的springboot代码生成器

    目录 ⚡Introduction ✔️Release Features Quick Start Examples 1.Controller模板代码示例 2.Service模板代码示例 3.Servic ...

  10. 控制台报错 [WDS] Disconnected!

    Webpack 的 HMR 功能,是通过 WebSocket 实现的推送 JSON Patch,同时需要第三方库支持. 具体解决方案: 热加载(HMR)是 Webpack Dev Server 最强大 ...