传送门
题解:
BZOJ能过,数据不算水。
然而DarkBZOJ和洛谷不知道为什么卡精度,可能是因为加强了数据???
注意到抛物线可以表示为 y = a x 2 + b x y=ax^2+bx y=ax2+bx,列出不等式之后发现就是一个对于 a , b a,b a,b的线性限制,直接上半平面交就行了,排序可以在最开始排一次,后面直接做就行了。
代码:
#include<bits/stdc++.h>
#define ll long long
#define re register
#define cs const
#define double long double
using std::cerr;
using std::cout;
cs double eps=1e-12,INF=1e12;
struct Pnt{
double x,y;Pnt(){}Pnt(double _x,double _y):x(_x),y(_y){}
friend Pnt operator+(cs Pnt &a,cs Pnt &b){return Pnt(a.x+b.x,a.y+b.y);}
friend Pnt operator-(cs Pnt &a,cs Pnt &b){return Pnt(a.x-b.x,a.y-b.y);}
friend Pnt operator*(cs Pnt &a,double b){return Pnt(a.x*b,a.y*b);}
friend double operator*(cs Pnt &a,cs Pnt &b){return a.x*b.y-a.y*b.x;}
};
struct Line{
Pnt s,e;double rad;Line(){}
Line(cs Pnt &_s,cs Pnt &_e):s(_s),e(_e),rad(atan2(e.y-s.y,e.x-s.x)){}
friend bool operator<(cs Line &a,cs Line &b){
return a.rad!=b.rad?a.rad<b.rad:(b.e-a.s)*(b.s-a.s)>0;
}
};
inline Pnt inter(cs Line &a,cs Line &b){
double s1=(a.e-a.s)*(b.s-a.s);
double s2=(b.e-a.s)*(a.e-a.s);
double k=s1/(s1+s2);
return b.s+(b.e-b.s)*k;
}
inline bool judge(cs Line &a,cs Line &b,cs Line &c){
return (c.e-c.s)*(inter(a,b)-c.s)<0;
}
#define se second
#define fi first
cs int N=2e5+7;
std::pair<Line,int> l[N];
Line q[N],p[N];int m,n,tot,h,t;
void init(){std::sort(l+1,l+m+1);}
bool check(int x){
tot=0;
for(int re i=1;i<=m;++i)
if(l[i].se<=x&&l[i].fi.rad!=p[tot].rad)
p[++tot]=l[i].fi;
q[h=1]=p[1];q[t=2]=p[2];
for(int re i=3;i<=tot;++i){
while(h<t&&judge(q[t-1],q[t],p[i]))--t;
while(h<t&&judge(q[h+1],q[h],p[i]))++h;
q[++t]=p[i];
}while(h<t&&judge(q[t-1],q[t],q[h]))--t;
while(h<t&&judge(q[h+1],q[h],q[t]))++h;
return t-h>1;
}
void Main(){
scanf("%d",&n);
for(int i=1;i<=n;++i){
double a,b1,b2;scanf("%Lf%Lf%Lf",&a,&b1,&b2);
l[++m]=std::make_pair(Line(Pnt(0,b1/a),Pnt(1,b1/a-a)),i);
l[++m]=std::make_pair(Line(Pnt(1,b2/a-a),Pnt(0,b2/a)),i);
}
l[++m]=std::make_pair(Line(Pnt(-INF,eps),Pnt(-eps,eps)),0);
l[++m]=std::make_pair(Line(Pnt(-eps,eps),Pnt(-eps,INF)),0);
l[++m]=std::make_pair(Line(Pnt(-eps,INF),Pnt(-INF,INF)),0);
l[++m]=std::make_pair(Line(Pnt(-INF,INF),Pnt(-INF,eps)),0);
init();int l=1,r=n;
while(l<r){
int mid=(l+r+1)>>1;
check(mid)?l=mid:r=mid-1;
}cout<<l<<"\n";
}
void file(){
#ifdef zxyoi
freopen("arrow.in","r",stdin);
#endif
}
signed main(){file();Main();return 0;}