凸包第一题。

自己认为自己写的是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. 【春节版】年度精品 XP,32/64位Win7,32/64位Win8,32/64位Win10系统

    本系统是10月5日最新完整版本的Windows10 安装版镜像,win10正式版,更新了重要补丁,提升应用加载速度,微软和百度今天宣布达成合作,百度成为win10 Edge浏览器中国默认主页和搜索引擎 ...

  2. UVA 1347 Tour 双调TSP

    TSP是NP难,但是把问题简化,到最右点之前的巡游路线只能严格向右,到最右边的点以后,返回的时候严格向左,这个问题就可以在多项式时间内求出来了. 定义状态d[i][j]表示一个人在i号点,令一个人在j ...

  3. synchronized关键字修饰非静态方法与静态方法的区别

    这里我们先创建ObjLock类,并实现Runnable接口.并创建一个Demo类,具有被synchronized关键字修饰的非静态方法与静态方法. 非静态方法 public class ObjLock ...

  4. caffe修改需要的东西 6:40

    https://blog.csdn.net/zhaishengfu/article/details/51971768?locationNum=3&fps=1

  5. 拼凑json的实例

    一,拼凑  json 串 并传到后台 function writeToJson(num){ var i = 1; var jsonData = "["; for(i=1;i< ...

  6. WinPcap过滤串表达式的语法

    注意:这篇文档取自tcpdump的指南.原始的版本 www.tcpdump.org 找到.   wpcap的过滤器是以已声明的谓词语法为基础的.过滤器是一个ASCII字符串,它包含了一个过滤表达式.p ...

  7. 【OS_Linux】清空终端屏幕的方法

    使用clear命令或Ctrl+L组合键来清空终端屏幕,它不是真正的清空了,而是给人以错觉,当向上滚动鼠标后发现屏幕的内容依然在. 使用printf '\033c'才真正意义上清空了屏幕,它同DOS下的 ...

  8. Ubuntu 下的aegisub安装

    大家用开源的软件用习惯了.推荐大家使用一下字幕编辑软件 分享的是Ubuntu下的安装教程: $ sudo add-apt-repository ppa:djcj/aegisub $ sudo apt- ...

  9. Spring容器的理解

    控制反转(IOC,Inversion Of Contorl)和依赖注入(DI,Dependency Injection) IOC是一个宽泛的概念:对某事物的控制权由A转移到B. DI是实现IOC的一种 ...

  10. Spring中线程池的使用

    <bean id="threadPoolTaskExecutor" class="org.springframework.scheduling.concurrent ...