hdu1392凸包裸题
//极角排序
#include <bits/stdc++.h>
#define sqr(x) ((x)*(x))
using namespace std;
int n,st[],top;
struct POI
{
int x,y;
POI()
{
x=y=;
}
POI(int _x,int _y)
{
x=_x;y=_y;
}
} p[];
int cross(POI x,POI y)
{
return x.x*y.y-x.y*y.x;
}
double dis(POI x,POI y)
{
return sqrt(sqr(x.x-y.x)+sqr(x.y-y.y));
}
POI operator-(POI x,POI y)
{
return POI(x.x-y.x,x.y-y.y);
}
bool com(POI x,POI y)
{
return(cross(x-p[],y-p[])> || cross(x-p[],y-p[])== && dis(x,p[])<dis(y,p[]));
}
int main()
{
for(scanf("%d",&n);n;scanf("%d",&n))
{
for(int i=;i<=n;i++)
scanf("%d%d",&p[i].x,&p[i].y);
if(n==)//wtf
{
printf("%.2f\n",dis(p[],p[]));
continue;
}
int id=;
for(int i=;i<=n;i++)
if(p[i].x<p[id].x || p[i].x==p[id].x && p[i].y<p[id].y) id=i;
swap(p[],p[id]);
sort(p+,p+n+,com);
st[top=]=st[]=;
for(int i=;i<=n;i++)
{
while(top && cross(p[st[top]]-p[st[top-]],p[i]-p[st[top]])<) --top;
st[++top]=i;
}
double len=;
// puts("");
// for(int i=1;i<=top;i++)
// printf("%d %d\n",p[st[i]].x,p[st[i]].y);
st[++top]=;
for(int i=;i<top;i++)
len+=dis(p[st[i]],p[st[i+]]);
printf("%.2f\n",len);
}
return ;
}
hdu1392凸包裸题的更多相关文章
- hdu 1392 Surround the Trees 凸包裸题
Surround the Trees Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- poj 1113 wall(凸包裸题)(记住求线段距离的时候是点积,点积是cos)
Wall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 43274 Accepted: 14716 Descriptio ...
- 【填坑】bzoj3224 splay裸题
人生第一道splay不出所料是一道裸题,一道水题,一道2k代码都不到的题 #include <cstdio> ,n,p,q; ],c[][],size[],sp[]; void rot(i ...
- tarjan讲解(用codevs1332(tarjan的裸题)讲解)
主要借助这道比较裸的题来讲一下tarjan这种算法 tarjan是一种求解有向图强连通分量的线性时间的算法.(用dfs来实现) 如果两个顶点可以相互通达,则称两个顶点强连通.如果有向图G的每两个顶点都 ...
- LCT裸题泛做
①洞穴勘测 bzoj2049 题意:由若干个操作,每次加入/删除两点间的一条边,询问某两点是否连通.保证任意时刻图都是一个森林.(两点之间至多只有一条路径) 这就是个link+cut+find roo ...
- 贴一下WC总结里提到的那道裸题吧。。。
[bzoj4034][HAOI2015]T2 试题描述 有一棵点数为 N 的树,以点 1 为根,且树点有边权.然后有 M 个 操作,分为三种: 操作 1 :把某个节点 x 的点权增加 a . 操作 2 ...
- HDU 1102 最小生成树裸题,kruskal,prim
1.HDU 1102 Constructing Roads 最小生成树 2.总结: 题意:修路,裸题 (1)kruskal //kruskal #include<iostream> ...
- hdu Flow Problem (最大流 裸题)
最大流裸题,贴下模版 view code#include <iostream> #include <cstdio> #include <cstring> #incl ...
- POJ 3468 线段树裸题
这些天一直在看线段树,因为临近期末,所以看得断断续续,弄得有些知识点没能理解得很透切,但我也知道不能钻牛角尖,所以配合着刷题来加深理解. 然后,这是线段树裸题,而且是最简单的区间增加与查询,我参考了A ...
随机推荐
- 搭建LoadRunner中的场景(一) 创建场景
一.创建场景 1. 使用场景创建设置对话框 场景分类: 1. 人工场景:相比面向目标场景,人工场景在实际工作中的应用更为广泛. 2. 面向目标场景:预先定义了一个测试目标,LoadRunner将根据这 ...
- ES忽略TF-IDF评分——使用constant_score
Ignoring TF/IDF Sometimes we just don’t care about TF/IDF. All we want to know is that a certain wor ...
- JavaMail API的应用
JavaMail API 是一个用于阅读.编写和发送电子消息的可选包(标准扩展),用来创建邮件用户代理(Mail User Agent,MUA)类型程序. JavaMail API 需要 JavaBe ...
- L87
Fear Makes Art More Engaging Emmanuel Kant spoke often about the sublime, and specifically how art b ...
- codeforces 703D D. Mishka and Interesting sum(树状数组)
题目链接: D. Mishka and Interesting sum time limit per test 3.5 seconds memory limit per test 256 megaby ...
- STM32中IO口的8中工作模式
该文摘自:http://blog.csdn.net/kevinhg/article/details/17490273 一.推挽输出:可以输出高.低电平,连接数字器件:推挽结构一般是指两个三极管分别受两 ...
- 【Lintcode】013.strStr
题目: For a given source string and a target string, you should output the first index(from 0) of targ ...
- bzoj1072Perm——状压DP
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1072 数字串最多只有10位,所以考虑用状压: 压缩的状态是哪些数字被用过,这样可以从一种状态 ...
- Scala学习——可变参数(初)
Scala 通过在参数的类型之后放一个星号来设置可变参数(可重复的参数) object Test { def main(args: Array[String]) { printStrings(&quo ...
- git push -u origin master error: failed to push some refs to
1.问题描述 $ git push -u origin master To github.com:[github_name]/[github_repository_name].git ! [rejec ...