凸包第一题。

自己认为自己写的是Andrew

其实就是xjb写出来居然过掉了测试。

刚开始把pi定义成了int,调了半天

#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define F(i,j,k) for (int i=j;i<=k;++i)
#define D(i,j,k) for (int i=j;i>=k;--i)
#define eps 1e-10
#define ll long long
#define mp make_pair const double pi=acos(-1.0); struct Vector{
double x,y;
void print()
{
printf("Vector - > (%.3f,%.3f)\n",x,y);
}
};
struct Point{
double x,y;
void print()
{
printf("Point - > (%.3f,%.3f)\n",x,y);
}
}; double operator * (Vector a,Vector b)
{return a.x*b.y-a.y*b.x;} Vector operator + (Vector a,Vector b)
{Vector ret;ret.x=a.x+b.x;ret.y=a.y+b.y;return ret;} Vector operator - (Vector a,Vector b)
{Vector ret;ret.x=a.x-b.x;ret.y=a.y-b.y;return ret;} Point operator + (Point a,Vector b)
{Point ret;ret.x=a.x+b.x;ret.y=a.y+b.y;return ret;} Vector operator * (Vector a,double b)
{Vector ret;ret.x=a.x*b;ret.y=a.y*b;return ret;} Vector operator - (Point a,Point b)
{Vector ret;ret.x=a.x-b.x;ret.y=a.y-b.y;return ret;} double dot (Vector a,Vector b)
{return a.x*b.x+a.y*b.y;} double len(Vector a)
{return sqrt(dot(a,a));} int n,l,top,sta[1005]; Point a[1005]; bool cmp(Point a,Point b)
{return fabs(a.x-b.x)<eps?a.y<b.y:a.x<b.x;} int main()
{
scanf("%d%d",&n,&l);
F(i,1,n) scanf("%lf%lf",&a[i].x,&a[i].y);
sort(a+1,a+n+1,cmp);
sta[++top]=1;
F(i,2,n)
{
while (top>=2&&((a[i]-a[sta[top]])*(a[sta[top]]-a[sta[top-1]]))<0) top--;
sta[++top]=i;
}
D(i,n-1,1)
{
while (top>=2&&((a[i]-a[sta[top]])*(a[sta[top]]-a[sta[top-1]]))<0) top--;
sta[++top]=i;
}
double ans=0;
F(i,2,top)
{
ans+=len(a[sta[i]]-a[sta[i-1]]);
// (a[sta[i]]-a[sta[i-1]]).print();
}
ans+=2.0*l*pi;
// printf("%.6f\n",pi);
// printf("%.6f\n",2.0*l*pi);
printf("%d\n",(int)(ans+0.5));
}

  

BZOJ 1113 Wall ——计算几何的更多相关文章

  1. POJ 1113 Wall(计算几何の凸包)

    Description Once upon a time there was a greedy King who ordered his chief Architect to build a wall ...

  2. poj 1113:Wall(计算几何,求凸包周长)

    Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28462   Accepted: 9498 Description ...

  3. POJ 1113 Wall(思维 计算几何 数学)

    题意 题目链接 给出平面上n个点的坐标.你需要建一个围墙,把所有的点围在里面,且围墙距所有点的距离不小于l.求围墙的最小长度. \(n \leqslant 10^5\) Sol 首先考虑如果没有l的限 ...

  4. 【POJ】1113 Wall(凸包)

    http://poj.org/problem?id=1113 答案是凸包周长+半径为l的圆的周长... 证明?这是个坑.. #include <cstdio> #include <c ...

  5. POJ 1113 Wall 凸包求周长

    Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 26286   Accepted: 8760 Description ...

  6. ●POJ 1113 Wall

    题链: http://poj.org/problem?id=1113 题解: 计算几何,凸包 题意:修一圈围墙把给出的点包围起来,且被包围的点距离围墙的距离不能小于L,求围墙最短为多少. 答案其实就是 ...

  7. 2018.07.04 POJ 1113 Wall(凸包)

    Wall Time Limit: 1000MS Memory Limit: 10000K Description Once upon a time there was a greedy King wh ...

  8. POJ 1113 Wall【凸包周长】

    题目: http://poj.org/problem?id=1113 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...

  9. BZOJ 1113: [Poi2008]海报PLA

    1113: [Poi2008]海报PLA Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1025  Solved: 679[Submit][Statu ...

随机推荐

  1. Vivado增量式编译

    Vivado 中的增量设计会重新利用已有的布局布线数据来缩短运行时间,并生成可预测的结果.当设计有 95% 以上的相似度时,增量布局布线的运行时间会比一般布局布线平均缩短2倍.若相似度低于80%,则使 ...

  2. OCR/Vote disk 维护操作: (添加/删除/替换/移动) (文档 ID 1674859.1)

    适用于: Oracle Database - Enterprise Edition - 版本 10.2.0.1 到 11.2.0.1.0 [发行版 10.2 到 11.2]本文档所含信息适用于所有平台 ...

  3. Xcode5 如何添加一个Github/Repository 并且Checkout

    1. 添加一个Account  也就是添加一个 Repository. In Xcode, choose Xcode > Preferences, and click Accounts. Pre ...

  4. python 1:列表和字典

    初学Python, 对列表和字典的嵌套使用. phoneBook = [] #列表 list peopleInfo = {} #字典 dict i=0 while i<3: peopleInfo ...

  5. 测试框架 Mocha 实例教程(转载:来自阮一峰的一篇文章)

    Mocha(发音"摩卡")诞生于2011年,是现在最流行的JavaScript测试框架之一,在浏览器和Node环境都可以使用. 所谓"测试框架",就是运行测试的 ...

  6. xampp中php手动升级

    http://windows.php.net/download/           //要下载的 里面有dll文件 http://www.php.net/downloads.php VC9 x86 ...

  7. 电商技术中企业数据总线ESB和注册服务管理的区别

    一.概述 1.什么是ESB 就是企业数据总线的意思,他的核心功能就是兼容各种协议接口,可以将数据在各种协议之间进行流转,并且可以针对数据格式进行编排转换. 异构系统,功能繁多,复杂 代表性的项目有:J ...

  8. html中注释的问题

    在修改jsp页面的时候遇到了一个有点难懂的注释,mark一下 <script> <!-- alert("js code"); //--> </scri ...

  9. UVa-213-信息解码

    这题的话,我们只要理解题意,应该就不算很难. 我们可以开一个二维数组,用来存放对应的编码字符,第一个下表是length,第二个下标是value,这样一来,我们在读入数据的时候就进行处理,然后想要使用的 ...

  10. Mysql 5.7在Linux上部署及远程访问

    序言:最近要和伙伴一起组队,做.NET Core项目.所以自己就租了一个阿里云服务器,并且装了Linux和MySQL.这里面我的Linux是CentOs 7. 第一步 添加Mysql Yum库 这里面 ...