HDU2907
来源:互联网 发布:linux 安装squid 编辑:程序博客网 时间:2024/06/07 04:08
代码还是WA的。还是没有处理好判断
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;const double eps=1e-10;int dcmp(double x){ if(fabs(x)<eps) return 0; return x<0?-1:1;}struct Point{ double x,y; Point(){} Point(double x,double y):x(x),y(y){} bool operator==(const Point& rhs)const { return dcmp(x-rhs.x)==0 && dcmp(y-rhs.y)==0; } bool operator<(const Point& rhs)const { return dcmp(x-rhs.x)<0 || (dcmp(x-rhs.x)==0 && dcmp(y-rhs.y)<0); }};typedef Point Vector;Vector operator-(Point A,Point B){ return Vector(A.x-B.x,A.y-B.y);}double Cross(Vector A,Vector B){ return A.x*B.y-A.y*B.x;}double Length(Point A,Point B){ return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));}int ConvexHull(Point *p,int n,Point *ch)//Çó͹°ü{ sort(p,p+n); n=unique(p,p+n)-p; int m=0; for(int i=0;i<n;i++) { while(m>1 && Cross(ch[m-1]-ch[m-2], p[i]-ch[m-2])<0) m--; ch[m++]=p[i]; } int k=m; for(int i=n-2;i>=0;i--) { while(m>k && Cross(ch[m-1]-ch[m-2], p[i]-ch[m-2])<0) m--; ch[m++]=p[i]; } if(n>1) m--; return m;}const int maxn=34;int n,t,_p,q;Point p[maxn],poly[maxn];int main(){ scanf("%d",&t); while(t--){ scanf("%d%d%d",&_p,&q,&n); for(int i=0;i<n;i++){ scanf("%lf%lf",&p[i].x,&p[i].y); } reverse(p,p+n); sort(p,p+n); int m=ConvexHull(p,n,poly); int a=0,b=0,cnt=0; //if(p[0]==poly[0])printf("hahahahha\n"); for(int i=0;i<n;i++){ if(p[i]==poly[cnt]&&p[(i+1)%n]==poly[(cnt+1)%m]){ b++;cnt++; } else if(p[i]==poly[cnt]&&!(p[(i+1)%n]==poly[(cnt+1)%m])){ i++;a++; } } int ans=-a*_p+b*q; printf("%d\n",ans>0?ans:0); } return 0;}
0 0
- HDU2907
- hdu2907 凸包+简单搜索
- Android 自定义控件之可多选课程日历CalendarView
- Hdu 5805 NanoApe Loves Sequence【思维题】
- Protocol Buffers使用教程
- poj 1185 炮兵阵地 3进制+轮廓线
- 邻接表存储的图的基本操作c++
- HDU2907
- Mesos源码分析(14): DockerContainerier运行一个Task
- (29)时间戳函数 (30)时间戳格式化
- 关于artTemplate不识别的问题
- spoj 694 Distinct Substrings 后缀数组
- 电子商务网站项目架构
- HDU 5804 Price List (简单题)
- Android开发实现用户头像更换
- Ubuntu启动/引导修复+重新设置直接进入windows启动项选择菜单