【BZOJ 1069】【SCOI 2007】最大土地面积 凸包+旋转卡壳
因为凸壳上对踵点的单调性所以旋转卡壳线性绕一圈就可以啦啦啦~~~
先求凸包,然后旋转卡壳记录$sum1$和$sum2$,最后统计答案就可以了
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define read(x) x=getint()
#define N 2003
using namespace std;
inline int dcmp(double x) {return fabs(x) < 1e-6 ? 0 : (x < 0 ? -1 : 1);}
struct Point {
double x, y;
Point(double _x = 0, double _y = 0) : x(_x), y(_y) {}
} a[N], tu[N];
Point operator - (Point a, Point b) {
return Point(a.x - b.x, a.y - b.y);
}
inline double Cross(Point a, Point b) {
return a.x * b.y - a.y * b.x;
}
inline double S(Point a, Point b, Point c) {
return Cross(a - c, b - c);
} int n, top = 0;
double sum1[N][N], sum2[N][N];
inline bool cmp(Point X, Point Y) {
return X.y == Y.y ? X.x < Y.x : X.y < Y.y;
}
inline void mktb() {
for(int i = 1; i <= n; ++i) {
while (top > 1 && dcmp(S(tu[top], a[i], tu[top-1])) != 1)
--top;
tu[++top] = a[i];
}
int k = top;
for(int i = n-1; i > 0; --i) {
while (top > k && dcmp(S(tu[top], a[i], tu[top - 1])) != 1)
--top;
tu[++top] = a[i];
}
tu[0] = tu[top - 1];
n = top - 1;
}
inline void mksum() {
int nxt, j;
for(int i = 0; i < n; ++i) {
nxt = (i + 2) % n;
for(int tmp = 1; tmp <= n - 2; ++tmp) {
j = (i + tmp) % n;
while (S(tu[j], tu[nxt], tu[i]) < S(tu[j], tu[(nxt + 1) % n], tu[i]))
nxt = (nxt + 1) % n;
sum1[i][j] = S(tu[j], tu[nxt], tu[i]);
}
nxt = (i - 2 + n) % n;
for(int tmp = 1; tmp <= n - 2; ++tmp) {
j = (i - tmp + n) % n;
while (S(tu[nxt], tu[j], tu[i]) < S(tu[(nxt - 1 + n) % n], tu[j], tu[i]))
nxt = (nxt - 1 + n) % n;
sum2[i][j] = S(tu[nxt], tu[j], tu[i]);
}
}
}
inline void AC() {
double ans = 0;
for(int i = 0; i < n - 2; ++i)
for(int j = i + 2; j < n; ++j)
ans = max(ans, sum1[i][j] + sum2[i][j]);
printf("%.3lf\n", ans / 2);
}
int main() {
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
scanf("%lf%lf", &a[i].x, &a[i].y);
sort(a + 1, a + n + 1, cmp);
mktb();
mksum();
AC();
return 0;
}
没什么可说的了╮(๑•́ ₃•̀๑)╭
【BZOJ 1069】【SCOI 2007】最大土地面积 凸包+旋转卡壳的更多相关文章
- bzoj 1069: [SCOI2007]最大土地面积 凸包+旋转卡壳
题目大意: 二维平面有N个点,选择其中的任意四个点使这四个点围成的多边形面积最大 题解: 很容易发现这四个点一定在凸包上 所以我们枚举一条边再旋转卡壳确定另外的两个点即可 旋(xuan2)转(zhua ...
- bzoj1069: [SCOI2007]最大土地面积 凸包+旋转卡壳求最大四边形面积
在某块平面土地上有N个点,你可以选择其中的任意四个点,将这片土地围起来,当然,你希望这四个点围成的多边形面积最大. 题解:先求出凸包,O(n)枚举旋转卡壳,O(n)枚举另一个点,求最大四边形面积 /* ...
- bzoj 1185 [HNOI2007]最小矩形覆盖 凸包+旋转卡壳
题目大意 用最小矩形覆盖平面上所有的点 分析 有一结论:最小矩形中有一条边在凸包的边上,不然可以旋转一个角度让面积变小 简略证明 我们逆时针枚举一条边 用旋转卡壳维护此时最左,最右,最上的点 注意 注 ...
- luogu P4166 [SCOI2007]最大土地面积 凸包 旋转卡壳
LINK:最大土地面积 容易想到四边形的边在凸包上面 考虑暴力枚举凸包上的四个点计算面积. 不过可以想到可以直接枚举对角线的两个点找到再在两边各找一个点 这样复杂度为\(n^3\) 可以得到50分. ...
- BZOJ 1069 Luogu P4166 最大土地面积 (凸包)
题目链接: (bzoj)https://www.lydsy.com/JudgeOnline/problem.php?id=1069 (luogu)https://www.luogu.org/probl ...
- [BZOJ1069][SCOI2007]最大土地面积 凸包+旋转卡壳
1069: [SCOI2007]最大土地面积 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 3669 Solved: 1451[Submit][Sta ...
- [USACO2003][poj2187]Beauty Contest(凸包+旋转卡壳)
http://poj.org/problem?id=2187 题意:老题了,求平面内最远点对(让本渣默默想到了悲剧的AHOI2012……) 分析: nlogn的凸包+旋转卡壳 附:http://www ...
- UVA 4728 Squares(凸包+旋转卡壳)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=17267 [思路] 凸包+旋转卡壳 求出凸包,用旋转卡壳算出凸包的直 ...
- Code Chef GEOCHEAT(凸包+旋转卡壳+随机化)
题面 传送门 题解 以下记\(S_i=\{1,2,3,...,i\}\) 我们先用凸包+旋转卡壳求出直径的长度,并记直径的两个端点为\(i,j\)(如果有多条直径随机取两个端点) 因为这个序列被\(r ...
随机推荐
- Caffe fine-tuning 微调网络
转载请注明出处,楼燚(yì)航的blog,http://www.cnblogs.com/louyihang-loves-baiyan/ 目前呢,caffe,theano,torch是当下比较流行的De ...
- 拓扑排序 POJ2367Genealogical tree[topo-sort]
---恢复内容开始--- Genealogical tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4875 A ...
- Vijos1392拼拼图的小衫[背包DP|二维信息DP]
背景 小杉的幻想来到了经典日剧<死亡拼图>的场景里……被歹徒威胁,他正在寻找拼图(-.-干嘛幻想这么郁闷的场景……). 突然广播又响了起来,歹徒竟然又有了新的指示. 小杉身为新一代的汤浅, ...
- 微软极品工具箱-Sysinternals Suite
工具包由来 Sysinternals Suite是微软发布的一套非常强大的免费工具程序集,一共包括74个windows工具.Sysinternals是Winternals公司提供的免费工具,Winte ...
- MIT License
早上看到微软的UWP例子,在代码里看到 Copyright (c) Microsoft. All rights reserved.// This code is licensed under the ...
- 云计算之路-阿里云上:RDS用户的烦恼
http://www.cnblogs.com/cmt/p/3586029.html *博主注:阿里云数据库真的这么可笑?
- Hibernate延迟加载Lazy
Hibernate延迟加载Lazy 延迟加载(lazy load)又称为懒加载,延迟加载的机制是为了避免一些无谓性能的开销而提出来的,所谓延迟加载就是当在真正需要数据的时候,才真正执行数据加载操作 如 ...
- maven总结5
上篇文章中项目最终发布的release仓库和快照仓库都是nexus的默认仓库,若所有的本地开发项目版本都发布到同一个仓库,可能会造成冲突.因此,我们可以为每一个项目创建一组仓库(快照版本和releas ...
- tyvj[1089]smrtfun
描述 现有N个物品,第i个物品有两个属性A_i和B_i.在其中选取若干个物品,使得sum{A_i + B_i}最大,同时sum{A_i},sum{B_i}均非负(sum{}表示求和). 输入格式 ...
- zoj 1610
Count the Colors Time Limit: 2 Seconds Memory Limit: 65536 KB Painting some colored segments on ...