博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
BZOJ-1069 [SCOI2007]最大土地面积
阅读量:4690 次
发布时间:2019-06-09

本文共 1371 字,大约阅读时间需要 4 分钟。

先把位于凸包的点求出,然后n^2枚举每两个点x,y,接着左右边找个离线最远的点。

可以知道,当x不变y单调递增时,两边距离最远的两点也在单调递增。

于是可以使用旋转卡壳。

#include 
#include
#include
#include
#include
#include
#include
#define rep(i, l, r) for(int i=l; i<=r; i++)#define down(i, l, r) for(int i=l; i>=r; i--)#define maxn 2009#define pi acos(-1)#define eps 1e-11using namespace std;inline int read(){ int x=0, f=1; char ch=getchar(); while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();} while (isdigit(ch)) x=x*10+ch-'0', ch=getchar(); return x*f;}struct P{double x, y;} p[maxn], s[maxn];P operator - (P a, P b){return (P){a.x-b.x, a.y-b.y};}double operator * (P a, P b){return a.x*b.y-a.y*b.x;}double dis(P a, P b){return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}bool cmp(P a, P b){ double t=(a-p[1])*(b-p[1]); if (t==0) return dis(a, p[1])
1 && (p[i]-s[top-1])*(s[top]-s[top-1])<=0) top--; s[++top]=p[i]; } s[top+1]=p[1]; int a, b; rep(x, 1, top) { a=x%top+1; b=(x+2)%top+1; rep(y, x+2, top) { while (a%top+1!=y && (s[y]-s[x])*(s[a+1]-s[x])>(s[y]-s[x])*(s[a]-s[x])) a=a%top+1; while (b%top+1!=x && (s[b+1]-s[x])*(s[y]-s[x])>(s[b]-s[x])*(s[y]-s[x])) b=b%top+1; ans=max((s[y]-s[x])*(s[a]-s[x])+(s[b]-s[x])*(s[y]-s[x]), ans); } } printf("%.3lf\n", ans/2); return 0;}

  

转载于:https://www.cnblogs.com/NanoApe/p/4480034.html

你可能感兴趣的文章
17级单片机期中测试题目
查看>>
JS 只能输入数字和两位小数的JS
查看>>
(转)java位运算
查看>>
浅析Symbol
查看>>
【狼窝乀野狼】Serializer妙手回春
查看>>
六张图教你交易美国5月非农数据
查看>>
信息模型之项目域
查看>>
第二十三模板 18.3.4多重集合 multiset
查看>>
Hibernate4.3配置
查看>>
[原]Ubuntu 下安装apache+PHP
查看>>
妙味——getByClass
查看>>
JavaScript 严格模式(use strict)
查看>>
Hibernate学习笔记
查看>>
Java接口
查看>>
HTML5 初步了解
查看>>
在CI框架中的配置整合amfphp
查看>>
蓝桥杯 ——无重复组合——C++
查看>>
React Native在开发过程中遇到的一些问题(俗称:坑)
查看>>
自控力阅读思维导图
查看>>
结构体的应用-成绩录入初步
查看>>