#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. ng4转义html

    https://stackoverflow.com/questions/31548311/angular-html-binding <div [innerHTML]="content& ...

  2. 安卓的progress

    https://www.cnblogs.com/wolipengbo/archive/2013/10/23/3383667.html

  3. 最小k度最小生成树模板

    代码是抄的 题解是瞄的 可我想学习的心是真的嘤嘤嘤 然而 还是上传一份ioi大神的论文吧 链接:https://pan.baidu.com/s/1neIW9QeZEa0hXsUqJTjmeQ 密码:b ...

  4. (转)Python中实现带Cookie的Http的Post请求

    转自crifan: http://www.crifan.com/python_http_post_request_with_cookie/ . . . .

  5. 《vue.js实战》练习---数字输入框组件

    html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  6. Lucene4.6 把时间信息写入倒排索引的Offset偏移量中,并实现按时间位置查询

    有个新的技术需求,需要对Lucene4.x的源码进行扩展,把如下的有时间位置的文本写入倒排索引,为此,我扩展了一个TimeTokenizer分词器,在这个分词器里将时间信息写入 偏移量Offset中. ...

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

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

  8. [bzoj2186][Sdoi2008]沙拉公主的困惑——数论

    题目大意 求 \[\sum_{i = 1}^{N!} [gcd(i, M!) = 1]\] 题解 显然,题目就是求 \[N!(1-\frac{1}{p_1})(1-\frac{1}{p_2})...\ ...

  9. bzoj 2064 DP

    这道题可以抽象成两个数列,将一个数列变换为另一个 数列的代价最小 首先我们可以处理出所有的状态代表,对于每个状态 用二进制来表示,代表的是两个数列中的每一项选还是不选 那么答案最多为n1+n2-2,也 ...

  10. LCD实验学习笔记(四):系统时钟

    一般CPU频率(FCLK)高于内存.网卡等设备频率(HCLK),而串口.USB.I2C等设备频率(PCLK)更低. 系统时钟: 系统时钟源为晶振,初始频率12MHz. 通过设置MPLLCON寄存器的M ...