#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define N 5001
struct Point{int x,y;}p[N],bao[N];
bool operator < (Point a,Point b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
typedef long long ll;
typedef Point Vector;
Vector operator - (Point a,Point b){return (Vector){a.x-b.x,a.y-b.y};}
ll Cross(Vector a,Vector b){return a.x*b.y-a.y*b.x;}
double sqr(int x){return (double)x*(double)x;}
double dis(Point a,Point b){return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));}
int n,en;
double ans;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;++i)
scanf("%d%d",&p[i].x,&p[i].y);
sort(p+1,p+1+n);
for(int i=1;i<=n;++i)
{
while(en>1&&Cross(bao[en]-bao[en-1],p[i]-bao[en])<=0)
--en;
bao[++en]=p[i];
}
int half=en;
for(int i=n-1;i;--i)
{
while(en>half&&Cross(bao[en]-bao[en-1],p[i]-bao[en])<=0)
--en;
bao[++en]=p[i];
}
for(int i=2;i<=en;++i)
ans+=dis(bao[i],bao[i-1]);
printf("%.2f\n",ans+dis(bao[1],bao[en]));
return 0;
}

【计算几何】【凸包】bzoj1670 [Usaco2006 Oct]Building the Moat护城河的挖掘的更多相关文章

  1. BZOJ1670 [Usaco2006 Oct]Building the Moat护城河的挖掘

    裸的凸包...(和旋转卡壳有什么关系吗...蒟蒻求教T T) 话说忘了怎么写了...(我以前都是先做上凸壳再做下凸壳的说) 于是看了下hzwer的写法,用了向量的点积,方便多了,于是果断学习(Orz) ...

  2. bzoj 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘 -- 凸包

    1670: [Usaco2006 Oct]Building the Moat护城河的挖掘 Time Limit: 3 Sec  Memory Limit: 64 MB Description 为了防止 ...

  3. BZOJ_1670_[Usaco2006 Oct]Building the Moat护城河的挖掘_求凸包

    BZOJ_1670_[Usaco2006 Oct]Building the Moat护城河的挖掘_求凸包 Description 为了防止口渴的食蚁兽进入他的农场,Farmer John决定在他的农场 ...

  4. 【BZOJ】1670: [Usaco2006 Oct]Building the Moat护城河的挖掘(凸包)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1670 裸打了凸包.. #include <cstdio> #include <cs ...

  5. bzoj 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘【凸包】

    凸包模板 #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> ...

  6. 牛客假日团队赛5J 护城河 bzoj 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘 (凸包的周长)

    链接:https://ac.nowcoder.com/acm/contest/984/J 来源:牛客网 护城河 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言6 ...

  7. bzoj 1670 [Usaco2006 Oct]Building the Moat护城河的挖掘——凸包

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1670 用叉积判断.注意两端的平行于 y 轴的. #include<cstdio> ...

  8. BZOJ 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘

    Description 求凸包周长. Sol 凸包+计算几何. 这好像叫什么 Graham Scan 算法... 这个可以求凸包的周长,直径,面积. 选择一个基点,然后按极角排序,最后用一个栈一直维护 ...

  9. [bzoj1670][Usaco2006 Oct]Building the Moat

    Description 为了防止口渴的食蚁兽进入他的农场,$Farmer John$决定在他的农场周围挖一条护城河.农场里一共有$N$股泉水,并且,护城河总是笔直地连接在河道上的相邻的两股泉水.护城河 ...

随机推荐

  1. Spring学习--Bean 之间的关系

    Bean 之间的关系:继承.依赖. Bean 继承: Spring 允许继承 bean 的配置 , 被继承的 bean 称为父 bean , 继承这个父 bean 的 bean 称为子 bean. 子 ...

  2. css之postion定位

    css position之初识 我们先看看position定位有那几个属性,下面是我从w3c的截图,为我们认识定位做初步的了解 通过上面这张图嘞,我们知道了position有5个属性,那么下面,我就来 ...

  3. 精通javascript笔记(智能社)——数字时钟

    JS代码: <script type="text/javascript">    window.onload=function(){ //小于10的数字补零及数字转字符 ...

  4. Notepad++64插件安装方法

    首先通过https://github.com/bruderstein/nppPluginManager/releases下载"nppPluginManager",下载解压后放到对应 ...

  5. kettle基础操作

    ETL:抽取(extract).转换(transform).加载(load)至目的端的过程: Kettle是ETL工具代表之一,是pentaho中的一个数据整合的一个组件.Kettle里包括多个Job ...

  6. Idea导入的工程看不到src等代码

    问题描述: 从其他地方拷贝过来的工程,在本地导入到idea中时,展示如下的页面,里面的其他文件都看不到. 解决办法:(不知道是具体的什么原因引起的) 1. 关闭IDEA, 2.然后删除项目文件夹下的. ...

  7. 【BZOJ2440】完全平方数 [莫比乌斯函数]

    完全平方数 Time Limit: 10 Sec  Memory Limit: 128 MB[Submit][Status][Discuss] Description 小X自幼就很喜欢数. 但奇怪的是 ...

  8. DotNETCore 学习笔记 配置

    Configuration var builder = new ConfigurationBuilder(); builder.AddInMemoryCollection(); var config ...

  9. Jackson对多态和多子类序列化的处理配置

    目录 Jackson 多态类型的处理 Jackson Jackson可以轻松的将Java对象转换成json对象和xml文档,同样也可以将json.xml转换成Java对象. 多态类型的处理 jacks ...

  10. Mac自带的SSH客户端

    https://segmentfault.com/q/1010000002806469 还能设置连接成持久连接,方便使用: ttps://www.zhihu.com/question/20541129 ...