BZOJ 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘|二维凸包
来源:互联网 发布:java 邮箱 后缀 编辑:程序博客网 时间:2024/05/21 13:58
纠结之后还是写的 水平序的凸包
极点序也不好写 可能有隐含错误
凸包裸题#include <cmath>#include <queue>#include <ctime>#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define ULL unsigned long longconst int mo=1e9+7;const int MAXN=5e3+10;const int MAXM=1e6+10;using namespace std;struct P{int x,y;}num[MAXN];bool cmp(P a,P b){if(a.x==b.x) return a.y<b.y;return a.x<b.x;}int q[MAXN],top;bool b[MAXN];int ff(int x1,int y1,int x2,int y2){return x1*y2-y1*x2;}int f(int z,int y,int x){return ff(num[y].x-num[x].x,num[y].y-num[x].y,num[z].x-num[y].x,num[z].y-num[y].y);}double dis(int x1,int y1,int x2,int y2){return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));}int main(){int n;scanf("%d",&n);for(int i=1;i<=n;i++) scanf("%d %d",&num[i].x,&num[i].y);sort(num+1,num+n+1,cmp);top=0;for(int i=1;i<=n;i++){while(top>1&&f(i,q[top],q[top-1])>0) top--;q[++top]=i;}for(int i=2;i<=top;i++) b[q[i]]=true;for(int i=n;i>=1;i--) if(!b[i]){while(f(i,q[top],q[top-1])>0) top--;q[++top]=i;}double ans=0;for(int i=2;i<=top;i++) ans+=dis(num[q[i]].x,num[q[i]].y,num[q[i-1]].x,num[q[i-1]].y);printf("%.2lf\n",ans);return 0;}
0 0
- BZOJ 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘|二维凸包
- bzoj 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘 (凸包)
- BZOJ 1670 [Usaco2006 Oct]Building the Moat护城河的挖掘 凸包
- bzoj 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘(凸包)
- [凸包]BZOJ 1670——[Usaco2006 Oct]Building the Moat护城河的挖掘
- bzoj 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘
- BZOJ 1670 [Usaco2006 Oct]Building the Moat护城河的挖掘
- BZOJ 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘
- 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘
- 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘
- 【BZOJ 1670】[Usaco2006 Oct]Building the Moat护城河的挖掘 裸凸包
- bzoj1670: [Usaco2006 Oct]Building the Moat护城河的挖掘 计算几何 凸包
- 【bzoj1670】[Usaco2006 Oct]Building the Moat护城河的挖掘 凸包
- [BZOJ1670][Usaco2006 Oct]Building the Moat护城河的挖掘(凸包)
- bzoj1670[Usaco2006 Oct]Building the Moat护城河的挖掘 凸包(Andrew)
- 【bzoj1670】[Usaco2006 Oct]Building the Moat护城河的挖掘 求凸包
- bzoj1670【Usaco2006 Oct】Building the Moat 护城河的挖掘
- [Usaco2006 Oct] Building the Moat护城河的挖掘
- 手机新闻阅读网站开发心得
- ECshop 数据库表结构
- ios瀑布流
- JSP页面数据传到另外一个JSP页面
- Android学习 游戏开发之打地鼠(二,游戏设计和主界面设计)
- BZOJ 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘|二维凸包
- 划一划新闻作手机端最简洁的新闻聚合网站
- java内存回收机制
- hdu 2084 dp入门 数塔问题
- AndroidStudio常用快捷键
- springMVC的生命周期
- VRay的常用渲染
- Java的泛型类
- Java多线程中的interrupt方法的使用