这题乍一看与半平面交并没有什么卵联系,然而每个靶子都可以转化为两个半平面。

scanf("%lf%lf%lf",&x,&ymin,&ymax);

于是乎就有ymin<=ax^2+bx<=ymax。(因为抛物线一定经过点(0,0),所以c=0)

考虑前一个有ax^2+bx>=ymin  <=>  ax^2+bx-ymin>=0。

#define A x^2

#define B x

#define C ymin

#define x' a

#define y' b

于是乎Ax'+By'+c>=0

这个式子貌似在哪见过的样子

于是乎上半平面交。

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define pi (acos(-1.0))
#define maxn 200100
#define double long double
const long long inf=1e15;
int n,tot,sum; double sqr(double x){return x*x;} struct point{
double x,y;
}p[maxn]; struct line{
point from,to;
int id;
double slope;
}l[maxn],q[maxn],a[maxn]; point operator -(point a,point b){return(point){a.x-b.x,a.y-b.y};}
point operator +(point a,point b){return(point){a.x+b.x,a.y+b.y};}
double operator *(point a,point b){return a.x*b.y-a.y*b.x;}
bool operator ==(line a,line b){return a.slope==b.slope;}
bool operator <(line a,line b){
return a.slope<b.slope||(a.slope==b.slope && (a.to-a.from)*(b.to-a.from)<);
} point getpoint(line a,line b){
double t1=(b.to-a.from)*(a.to-a.from),t2=(a.to-a.from)*(b.from-a.from);
double t=t1/(t1+t2);
return (point){(b.from.x-b.to.x)*t+b.to.x,(b.from.y-b.to.y)*t+b.to.y};
} bool check(line a,line b,line c){
point d=getpoint(a,b);
return (c.to-c.from)*(d-c.from)<;
} bool bo(int x){
int cnt=;
for (int i=;i<=sum;i++) if (l[i].id<=x) a[++cnt]=l[i];
int head=,tail=;
q[]=a[],q[]=a[];
for (int i=;i<=cnt;i++){
while (head<tail && check(q[tail-],q[tail],a[i])) tail--;
while (head<tail && check(q[head+],q[head],a[i])) head++;
q[++tail]=a[i];
}
while (head<tail && check(q[tail-],q[tail],q[head])) tail--;
while (head<tail && check(q[head+],q[head],q[tail])) head++;
return tail>head+;
} int main(){
scanf("%d",&n);
l[++tot].to=(point){-inf,inf},l[tot].from=(point){inf,inf};
l[++tot].to=(point){inf,inf},l[tot].from=(point){inf,-inf};
l[++tot].to=(point){inf,-inf},l[tot].from=(point){-inf,-inf};
l[++tot].to=(point){-inf,-inf},l[tot].from=(point){-inf,inf};
for (int i=;i<=n;i++){
double x,y1,y2;
scanf("%llf%llf%llf",&x,&y1,&y2);
double A=sqr(x),B=x,C=-y1;
l[++tot].from=(point){-,(A-C)/B},l[tot].to=(point){,(-A-C)/B},l[tot].id=i;
C=-y2;
l[++tot].from=(point){,(-A-C)/B},l[tot].to=(point){-,(A-C)/B},l[tot].id=i;
} for (int i=;i<=tot;i++) l[i].slope=atan2(l[i].to.y-l[i].from.y,l[i].to.x-l[i].from.x);
sort(l+,l+tot+);
sum=unique(l+,l+tot+)-l;
sum--;
int l=,r=n;
while (l<=r){
int mid=(l+r)>>;
if (bo(mid)) l=mid+;
else r=mid-;
}
printf("%d",r);
return ;
}

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

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

    题目大意: http://www.lydsy.com/JudgeOnline/problem.php?id=2732 题解: 这道题的做法我不想说什么了... 其他题解都有说做法... 即使是我上午做 ...

  2. bzoj 2732 射箭 半平面交

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

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

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

  4. [bzoj2732][HNOI2012]射箭

    Description 沫沫最近在玩一个二维的射箭游戏,如下图所示,这个游戏中的$x$轴在地面,第一象限中有一些竖直线段作为靶子,任意两个靶子都没有公共部分,也不会接触坐标轴.沫沫控制一个位于$(0, ...

  5. 【BZOJ-4515】游戏 李超线段树 + 树链剖分 + 半平面交

    4515: [Sdoi2016]游戏 Time Limit: 40 Sec  Memory Limit: 256 MBSubmit: 304  Solved: 129[Submit][Status][ ...

  6. poj3335 半平面交

    题意:给出一多边形.判断多边形是否存在一点,使得多边形边界上的所有点都能看见该点. sol:在纸上随手画画就可以找出规律:按逆时针顺序连接所有点.然后找出这些line的半平面交. 题中给出的点已经按顺 ...

  7. POJ3525 半平面交

    题意:求某凸多边形内部离边界最远的点到边界的距离 首先介绍半平面.半平面交的概念: 半平面:对于一条有向直线,它的方向的左手侧就是它所划定的半平面范围.如图所示: 半平面交:多个半平面的交集.有点类似 ...

  8. POJ 3130 How I Mathematician Wonder What You Are! /POJ 3335 Rotating Scoreboard 初涉半平面交

    题意:逆时针给出N个点,求这个多边形是否有核. 思路:半平面交求多边形是否有核.模板题. 定义: 多边形核:多边形的核可以只是一个点,一条直线,但大多数情况下是一个区域(如果是一个区域则必为 ).核内 ...

  9. bzoj2618[Cqoi2006]凸多边形 半平面交

    这是一道半平面交的裸题,第一次写半平面交,就说一说我对半平面交的理解吧. 所谓半平面交,就是求一大堆二元一次不等式的交集,而每个二元一次不等式的解集都可以看成是在一条直线的上方或下方,联系直线的标准方 ...

随机推荐

  1. localtime和localtime_r

    上程序: #include <cstdlib> #include <iostream> #include <time.h> #include <stdio.h ...

  2. Does not contain a valid host;port authority解决方法

    ERRORorg.apache.hadoop.hdfs.server.namenode.NameNode: java.lang.IllegalArgumentException: Does not c ...

  3. HW3.29

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  4. Codeforces149E - Martian Strings(KMP)

    题目大意 给定一个字符串T,接下来有n个字符串,对于每个字符串S,判断是否存在T[a-b]+T[c-d]=S(1 ≤ a ≤ b < c ≤ d ≤ length(T)) 题解 对于每个字符串S ...

  5. nyoj 915 +-字符串

    +-字符串 时间限制:1000 ms  |  内存限制:65535 KB 难度:1   描述 Shiva得到了两个只有加号和减号的字符串,字串长度相同.Shiva一次可以把一个加号和它相邻的减号交换. ...

  6. APNs消息推送完整讲解

    在项目的AppDelegate中的didFinishLaunchingWithOptions方法中加入下面的代码: [[UIApplication sharedApplication] registe ...

  7. background-position也许你没考虑到

    设置背景图片时不知你有没有遇到过背景位置的困扰,有没有深入思考过,background-position到底是什么,下面请各位看看我的理解. 简而言之就一句话,默认图片左上角居元素左上角的坐标,例如: ...

  8. WPF-21:WPF实现仿安卓的图案密码键盘(改进)

    前面写了个简单的实现( http://blog.csdn.net/yysyangyangyangshan/article/details/9280439),不过效果不太好,各个点之间没有连接起来.这里 ...

  9. SEAndroid安全机制对Binder IPC的保护分析

    在SEAndroid安全机制中,除了文件和属性,还有Binder IPC须要保护.Binder IPC是Android系统的灵魂,使用得相当广泛又频繁.比如,应用程序都是Binder IPC请求訪问系 ...

  10. 关于no system images installed for this target解决方法

    (1)国外网站都被屏蔽,连不上下载地址了 修改hosts文件(C:\Windows\System32\drivers\etc\hosts),在最后添加如下内容 127.0.0.1 localhost ...