题目大意:

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. 第8章 Foundation Kit介绍

    本文转载至  http://blog.csdn.net/mouyong/article/details/16947321 Objective-C是一门非常精巧实用的语言,目前我们还没有研究完它提供的全 ...

  2. hdu3579(线性同余方程组)

    Hello Kiki Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  3. spring mvc中的@PathVariable

    spring mvc中的@PathVariable是用来获得请求url中的动态参数的,十分方便,复习下: @Controller public class TestController { @Requ ...

  4. java.util包下面的类---------01---示意图

    一直在使用util包下面的这些类,甚至有些没用过的,想要都去认识认识他们!也许在未来的一天可以用到! 图太大不好截图!部分没有截全!

  5. 学习Sharding JDBC 从入门到出门-1

    感觉大神已经写好了,自己膜拜下下, 送上大神地址:http://www.cnblogs.com/zhongxinWang/p/4262650.html 这篇博客主要是理论的说明了什么是分库分表,路由等 ...

  6. 【python】-- 继承式多线程、守护线程

    继承式多线程 1.定义 继承式多线程是自己自定义类,去继承theading.Tread这个类,通过类实例.start()启动,去执行run方法中的代码. import threading import ...

  7. iOS线程浅析

    一.线程概述 1. iOS里面的线程按种类可分为同步线程和异步线程.同步线程指调用同步线程的地方必须等到同步线程运行完成才干够继续向下运行.而调用异步线程的地方则在运行完调用异步线程的语句后就能够继续 ...

  8. TextView属性

    TextView及其子类,当字符内容太长显示不下时可以省略号代替未显示的字符:省略号可以在显示区域的起始,中间,结束位置,或者以跑马灯的方式显示文字(textview的状态为被选中). 其实现只需在x ...

  9. nginx-gridfs的安装

    mongodb中gridfs适合存放视频和高清图片等等超大文件(小的文件建议不要存在mongodb中): 下面是在centos下配置nginx来訪问mongodb中的mp4文件: 1:安装nginx- ...

  10. spring项目改名后不能启动的原因及解决办法

    今日修改了一个spring项目的项目名称,修改后启动项目Debug as->Debug on server,过了很久也没有出现web首页,仔细看项目的定时器已经启动,eclipse的Consol ...