题目大意:

http://www.lydsy.com/JudgeOnline/problem.php?id=2732

题解:

这道题的做法我不想说什么了。。。

其他题解都有说做法。。。

即使是我上午做的题,晚上写的题解

看到这道题我就感觉到累.

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(int &x){
x=0;char ch;bool flag = false;
while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
inline int cat_max(const int &a,const int &b){return a>b ? a:b;}
inline int cat_min(const int &a,const int &b){return a<b ? a:b;}
const int maxn = 210010; const long double eps = 1e-18;
inline int dcmp(const long double &x){
if(x < eps && x > -eps) return 0;
return x > 0 ? 1 : -1;
}
struct Point{
long double x,y;
Point(){}
Point(const long double &a,const long double &b){
x=a;y=b;
}
};
typedef Point Vector;
Vector operator + (const Vector &a,const Vector &b){
return Vector(a.x+b.x,a.y+b.y);
}
Vector operator - (const Vector &a,const Vector &b){
return Vector(a.x-b.x,a.y-b.y);
}
Vector operator * (const Vector &a,const long double &b){
return Vector(a.x*b,a.y*b);
}
long double cross(const Vector &a,const Vector &b){
return a.x*b.y - a.y*b.x;
}
struct line{
Point p;
Vector v;
long double alpha;
int id;
line(){}
line(const Point &a,const Point &b,int i){
p = a;v = b;id = i;
alpha = atan2(v.y,v.x);
// printf("(%lf,%lf) got %lf\n",v.x,v.y,alpha);
}
};
Point lineInterion(const line &l1,const line &l2){
Vector u = l1.p - l2.p;
long double t = cross(l2.v,u)/cross(l1.v,l2.v);
return l1.p + l1.v*t;
}
bool onLeft(const Point &p,const line &l){
return dcmp(cross(l.v,p-l.p)) >= 0;
}
inline bool cmp(const line &a,const line &b){
return a.alpha < b.alpha;
}
line lines[maxn],q[maxn];
Point p[maxn];
int l,r;
inline bool halfInterion(int n){
l = 1;r = 1;q[1] = lines[1];
for(int i=2;i<=n;++i){
while(l < r && !onLeft(p[r-1],lines[i])) -- r;
while(l < r && !onLeft(p[l],lines[i])) ++ l;
if(dcmp(cross(q[r].v,lines[i].v)) == 0)
q[r] = onLeft(q[r].p,lines[i]) ? q[r] : lines[i];
else q[++r] = lines[i];
if(l < r) p[r-1] = lineInterion(q[r],q[r-1]);
}while(l < r && !onLeft(p[r-1],q[l])) -- r;
return (r-l > 1);
}
line a[maxn];
int n,cnt = 0,tot;
inline bool check(int mid){
tot = 0;
for(int i=1;i<=cnt;++i){
if(a[i].id > mid) break;
tot = i;
lines[i] = a[i];
}
sort(lines+1,lines+tot+1,cmp);
return halfInterion(tot);
}
const long double inf = 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0;
int main(){
read(n);
double v,L,R;
a[++cnt] = line(Point(-inf,-inf),Point(inf,0),0);
a[++cnt] = line(Point(inf,-inf),Point(0,inf),0);
a[++cnt] = line(Point(inf,inf),Point(-inf,0),0);
a[++cnt] = line(Point(-inf,inf),Point(0,-inf),0);
for(int i=1;i<=n;++i){
scanf("%lf%lf%lf",&v,&L,&R);
L -= eps;R += eps;
a[++cnt] = line(Point(0,R/v),Point(-1/v,1),i);
a[++cnt] = line(Point(0,L/v),Point(1/v,-1),i);
}
int l = 1,r = n,ans = 0;
while(l <= r){
int mid = (l+r) >> 1;
if(check(mid)) ans = mid,l = mid+1;
else r = mid-1;
}printf("%d\n",ans);
getchar();getchar();
return 0;
}

。。。 。。。

下面的那个Ac是粘的hzwer的代码...最上面的才是自己A的

bzoj 2732: [HNOI2012]射箭 半平面交的更多相关文章

  1. bzoj2732: [HNOI2012]射箭 半平面交

    这题乍一看与半平面交并没有什么卵联系,然而每个靶子都可以转化为两个半平面. scanf("%lf%lf%lf",&x,&ymin,&ymax); 于是乎就有 ...

  2. bzoj 2732 射箭 半平面交

    2732: [HNOI2012]射箭 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 2531  Solved: 848[Submit][Status] ...

  3. BZOJ 2732: [HNOI2012]射箭

    2732: [HNOI2012]射箭 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 2532  Solved: 849[Submit][Status] ...

  4. 洛谷P3222 [HNOI2012]射箭(计算几何,半平面交,双端队列)

    洛谷题目传送门 设抛物线方程为\(y=ax^2+bx(a<0,b>0)\),我们想要求出一组\(a,b\)使得它尽可能满足更多的要求.这个显然可以二分答案. 如何check当前的\(mid ...

  5. bzoj 4445 小凸想跑步 - 半平面交

    题目传送门 vjudge的快速通道 bzoj的快速通道 题目大意 问在一个凸多边形内找一个点,连接这个点和所有顶点,使得与0号顶点,1号顶点构成的三角形是最小的概率. 假设点的位置是$(x, y)$, ...

  6. bzoj 3190 赛车 半平面交

    直接写的裸的半平面交,已经有点背不过模板了... 这题卡精度,要用long double ,esp设1e-20... #include<iostream> #include<cstd ...

  7. BZOJ 4445 [Scoi2015]小凸想跑步:半平面交

    传送门 题意 小凸晚上喜欢到操场跑步,今天他跑完两圈之后,他玩起了这样一个游戏. 操场是个凸 $ n $ 边形,$ n $ 个顶点 $ P_i $ 按照逆时针从 $ 0 $ 至 $ n-1 $ 编号. ...

  8. BZOJ 1137: [POI2009]Wsp 岛屿 半平面交

    1137: [POI2009]Wsp 岛屿 Time Limit: 10 Sec  Memory Limit: 162 MBSec  Special JudgeSubmit: 165  Solved: ...

  9. BZOJ 1829 [Usaco2010 Mar]starc星际争霸 ——半平面交

    发现最终的结果只和$s1$,$s2$,$s3$之间的比例有关. 所以直接令$s3=1$ 然后就变成了两个变量,然后求一次半平面交. 对于每一个询问所属的直线,看看半平面在它的那一侧,或者相交就可以判断 ...

随机推荐

  1. 大组合数取模之lucas定理模板,1<=n<=m<=1e9,1<p<=1e6,p必须为素数

    typedef long long ll; /********************************** 大组合数取模之lucas定理模板,1<=n<=m<=1e9,1&l ...

  2. Python闲谈(二)聊聊最小二乘法以及leastsq函数

    1 最小二乘法概述 自从开始做毕设以来,发现自己无时无刻不在接触最小二乘法.从求解线性透视图中的消失点,m元n次函数的拟合,包括后来学到的神经网络,其思想归根结底全都是最小二乘法. 1-1 “多线→一 ...

  3. Collective Mindsets (easy)(逻辑题)

    Collective Mindsets (easy) Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d &am ...

  4. 开始翻译《Beginning SharePoint 2013 Development》

    伙同涂曙光@kaneboy 和柴晓伟@WindieChai 翻译Beginning SharePoint 2013 Development 作者是Steve Fox,传说中的Andrew Connel ...

  5. 记录-项目java项目框架搭建的一些问题(maven+spring+springmvc+mybatis)

    伴随着项目框架的落成后,本以为启动就能成功的,but.... 项目启动开始报错误1:java.lang.ClassNotFoundException: org.springframework.web. ...

  6. config相关操作(转)

    转自:http://www.cnblogs.com/kissdodog/archive/2013/04/16/3025315.html,这是一个专题,感觉比较好,有空可以看与一下 System.Con ...

  7. 如何下载symfony

    php -r "readfile('https://symfony.com/installer');" > symfony 可能无法下载,:那么你检查一下你的php.ini找 ...

  8. Excel 文件下载

    INCLUDE OLE2INCL * ALV输出   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'     EXPORTING       I_CALLBACK_PRO ...

  9. 关于date和String互相转换的问题

    其实原理很简单,就是将String类型的变量使用SimpleDateFormat来转换成Date,然后用getTime()方法比较 SimpleDateFormat sdf = new SimpleD ...

  10. R语言图形base系统(一)

           一般R作图有三大绘图系统:base系统.ggplot2绘图系统.lattice绘图系统.        本篇主要介绍base系统绘图时的图形参数.一般用plot()函数来完成.在R中,若 ...