X-man

导航

随笔分类 -  ACM--计算几何进阶

poj 1654 Area
摘要:#include#include#define Max 1000100char s[Max];struct Point{ int x,y;} p[Max];long long myfabs(long long x){ if(x#include#include#define Max 1000100#define eps 1e-12char s[Max];struct Point{ int x,y;} p[Max];long long myfabs(long long x){ if(x<0)x=-x; return x;}int xmult(Point p1,Poin... 阅读全文

posted @ 2013-08-04 17:32 雨钝风轻 阅读(275) 评论(0) 推荐(0)

poj 3348 Cows
摘要:#include#includeusing namespace std;#define Max 10100struct Point{ int x,y;}p[Max];int dis(Point p1,Point p2){ return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y);}int xmult(Point p1,Point p2,Point p0){ return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);}bool cmp(Point p1,Point p2){ ... 阅读全文

posted @ 2013-08-04 15:51 雨钝风轻 阅读(142) 评论(0) 推荐(0)

poj 1228 Grandpa's Estate
摘要:#include#includeusing namespace std;#define Max 1000struct Point{ int x,y;}p[Max],res[Max];int xmult(Point p1,Point p2,Point p0){ return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);}bool cmp(Point p1,Point p2){ if(p1.y=0;i--) { while(len!=top&&xmult(res[top],p[i],res[top-1])=3... 阅读全文

posted @ 2013-08-04 11:58 雨钝风轻 阅读(181) 评论(0) 推荐(0)

poj 2007 Scrambled Polygon
摘要:#include#includeusing namespace std;#define Max 60struct Point{ int x,y;} p[Max];int xmult(Point p1,Point p2,Point p0){ return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);}int pos;bool cmp(Point p1,Point p2){ if(xmult(p1,p2,p[pos])>0) return true; return false;}int main(){ ... 阅读全文

posted @ 2013-08-03 15:11 雨钝风轻 阅读(188) 评论(0) 推荐(0)

poj 1113 Wall
摘要:#include#include#includeusing namespace std;#define Max 1100#define PI 3.1415926struct Point{ int x,y;}p[Max];int dis(Point p1,Point p2){ return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y);}int xmult(Point p1,Point p2,Point p0){ return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);}bo... 阅读全文

posted @ 2013-08-03 11:42 雨钝风轻 阅读(134) 评论(0) 推荐(0)

poj 1696 Space Ant
摘要:#include#includeusing namespace std;const int Max=55;struct Point{ int x,y,num;} p[Max],res[Max];int pos;int xmult(Point p1,Point p2,Point p0){ return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);}int dis(Point p1,Point p2){ return (p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y);}bool cm... 阅读全文

posted @ 2013-08-03 10:20 雨钝风轻 阅读(328) 评论(0) 推荐(0)

poj 1410 Intersection
摘要:**必须注意几点1、文中给出的左上顶点和右下顶点不保证x1y2;即需要自己判断2、文中似乎没说,但必须这么认为:线段完全在矩形内部要返回T.3.判断两个线段相交时,注意它们在一条直线上的情况#includestruct Point{ int x,y;}pointc,point1,point2,point[5];struct Line{ Point a,b;}linex;int xmult(Point p1,Point p2,Point p0){ return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);}int dmult(... 阅读全文

posted @ 2013-07-24 20:06 雨钝风轻 阅读(160) 评论(0) 推荐(0)

poj 1066 Treasure Hunt (未完)
摘要:#include#include#include#define eps 1e-8#define zero(x) (((x)>0 ? (x):(-x))dis(point[0],*d)) return 1; return -1;}int main(){ int i,j,n,ans,tmp; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%lf%lf%lf%lf",&line[i].a.x,&line[i].a.y,&line[i].b.x,&line[i].b.y); 阅读全文

posted @ 2013-07-24 15:30 雨钝风轻 阅读(242) 评论(0) 推荐(0)

poj 2653 Pick-up sticks
摘要:#include#include#include#define eps 1e-8#define zero(x)(((x)>0 ? (x):(-x))<eps)struct Point{ double x,y;};struct Line{ Point a,b;}line[100100],tmp;int num[100100];double xmult(Point p1,Point p2,Point p0)//p0p1*p0p2 叉积{ return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);}double dmult(Poi... 阅读全文

posted @ 2013-07-24 10:50 雨钝风轻 阅读(233) 评论(0) 推荐(0)

POJ 1556 The Doors (未完)
摘要:…… 阅读全文

posted @ 2013-07-23 19:47 雨钝风轻 阅读(168) 评论(0) 推荐(0)

poj 1269 Intersecting Lines
摘要://判断直线有无交点//斜率相同再判断点是否在直线上//或一个#include#include#define eps 1e-8#define zero(x)(((x)>0 ? (x):(-x))<eps)struct Point{ double x,y;};struct Line{ Po... 阅读全文

posted @ 2013-07-23 18:07 雨钝风轻 阅读(290) 评论(0) 推荐(0)

poj 3304 Segments (题意理解出错,错误的只枚举了过线段的直线)
摘要://枚举过每一条线段的直线,//再判断其他线段的点在直线上或被直线穿过//即求直线与线段相交(叉积)#include#include#define esp 1e-8struct Node{ double x,y;} a[105],b[105],c[210],tmp1,tmp2;double cal(Node a,Node b,Node c)//ca*cb{ return ((a.x-c.x)*(b.y-c.y)-(b.x-c.x)*(a.y-c.y));}double diji(Node a,Node b,Node c)//ab·ac{ return (b.x-a.x)*(c... 阅读全文

posted @ 2013-07-23 10:21 雨钝风轻 阅读(300) 评论(0) 推荐(0)

POJ 2398 Toy Storage
摘要:#include#include#includeusing namespace std;#define Max 2000using namespace std;struct Node{ int x,y;}point1[Max],point2[Max],high,low,tmp;int n,tm[Max],ans[Max];bool cmp(Node a,Node b){ if(a.x0) return 1; return 0;}int search(){ int l=0,r=n-1,mid; while(l>1; if(cal(poin... 阅读全文

posted @ 2013-07-16 21:34 雨钝风轻 阅读(226) 评论(0) 推荐(0)

POJ 2318 TOYS
摘要:#include#include#define Max 5010struct node{int x,y;}low[Max],high[Max];node a,b;int n,m;int cal(node aa,node bb,node cc){//return (cc.x-aa.x)*(bb.y-aa.y)-(cc.y-aa.y)*(bb.x-aa.x);//第一种return (bb.x-cc.x)*(aa.y-cc.y)-(bb.y-cc.y)*(aa.x-cc.x);//第二种}int solve(node cc){int l,r,mid;l=0;r=n-1;while(l>1;i 阅读全文

posted @ 2013-07-16 19:36 雨钝风轻 阅读(171) 评论(0) 推荐(0)