POJ 2007 Scrambled Polygon
来源:互联网 发布:高速公路收费软件 编辑:程序博客网 时间:2024/05/22 03:38
POJ 2007 Scrambled Polygon
其实就是普通的凸包。
模板在手,一生无忧。。。
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<vector>using namespace std;#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)#define DOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)#define oo 1e6#define eps 1e-8#define nMax 100000#define pb push_back#define F first#define S second#define bug puts("OOOOh.....");#define zero(x) (((x)>0?(x):-(x))<eps)int dcmp(double x){ if(fabs(x)<eps) return 0; return x>0?1:-1;}class point {public: double x,y; point (double x=0,double y=0):x(x),y(y) {} void make(double _x,double _y) {x=_x;y=_y;} void read() { scanf("%lf%lf",&x,&y); } void out() { printf("(%.0f,%.0f)\n",x,y);} double len() { return sqrt(x*x+y*y); } point friend operator - (point const& u,point const& v) { return point(u.x-v.x,u.y-v.y); } point friend operator + (point const& u,point const& v) { return point(u.x+v.x,u.y+v.y); } double friend operator * (point const& u,point const& v) { return u.x*v.y-u.y*v.x; } double friend operator ^ (point const& u,point const& v) { return u.x*v.x+u.y*v.y; } point friend operator * (point const& u,double const& k) { return point(u.x*k,u.y*k); }friend bool operator < (point const& u,point const& v){if(dcmp(v.x-u.x)==0) return dcmp(u.y-v.y)<0;return dcmp(u.x-v.x)<0;}};typedef class line{public: point a,b; line() {} line (point a,point b):a(a),b(b){} void make(point u,point v) {a=u;b=v;} void read() { a.read(),b.read(); }}segment;int ConvexHull(point *p,int n,point *ret){sort(p,p+n);int m=0;for(int i=0;i<n;i++){while(m>1 && dcmp((ret[m-1]-ret[m-2])*(p[i]-ret[m-1]))<0) m--;ret[m++]=p[i];}int k=m;for(int i=n-2;i>=0;i--) {while(m>k && dcmp((ret[m-1]-ret[m-2])*(p[i]-ret[m-1]))<0) m--;ret[m++]=p[i];}if(n>1) m--;return m;}point p[nMax],q[nMax];int n;int main(){#ifndef ONLINE_JUDGEfreopen("input.txt","r",stdin);#endifn=0;while(~scanf("%lf%lf",&p[n].x,&p[n].y)) n++;int m=ConvexHull(p,n,q);int l;for(l=0;l<m;l++) if(dcmp(q[l].x-0)==0 && dcmp(q[l].y-0)==0) break;for(int i=0;i<m;i++) q[(i+l)%m].out();return 0;}
- poj 2007 Scrambled Polygon
- poj 2007 Scrambled Polygon
- POJ 2007 Scrambled Polygon
- POJ 2007 Scrambled Polygon
- POJ 2007 Scrambled Polygon
- POJ 2007 Scrambled Polygon
- POJ 2007 Scrambled Polygon
- poj 2007 Scrambled Polygon
- POJ 2007 Scrambled Polygon .
- POJ 2007 Scrambled Polygon
- poj 2007 Scrambled Polygon
- POJ 2007 Scrambled Polygon(几何)
- POJ 2007 Scrambled Polygon 笔记
- zoj 2352 || poj 2007 Scrambled Polygon
- poj 2007 Scrambled Polygon--按极角排序
- poj 2007 Scrambled Polygon 极角排序
- POJ 2007 Scrambled Polygon(极角排序)
- POJ 2007 Scrambled Polygon(凸包)
- U盘安装centOS6.2
- Java多线程——6 并发流程控制CountDownLatch、CycliBarrier
- 新手学Oracle数据库安装遇到问题
- Objective-C中的锁
- 2011 湖南省 ACM 程序设计竞赛 C题 多连通拼图 直接枚举就好了
- POJ 2007 Scrambled Polygon
- ext之实现列表(从后台数据库读取数据)
- Linux上文件的特殊权限SUID,SGID,SBIT详解
- 远程操作linux网络设置(六)- VNC安装配置Ubuntu(vnc4server )和CentOS(tigerVNC)
- 第12期中国智能家居主题沙龙将于8月28日在京举行
- jadclipse Myeclipse8.5反编译插件安装 eclipse的也类似
- android 创建图片的拷贝
- 学生信息管理系统
- REST四种请求(get,delete,put,post) 收集整理 之一