显示代码纯文本
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<deque>
using namespace std;
const int SIZEN=100010,INF=0x7fffffff/2;
typedef long long LL;
int N;
LL a,b,c,d;
int f[2*SIZEN]={0};
class poi
{
public:
LL x,y;
int id;
}P[2*SIZEN];
bool cmp(poi a,poi b)
{
if(a.x==b.x) return a.y<b.y;
return a.x<b.x;
}
int tr[SIZEN*2]={0};
void read()
{
scanf("%d",&N);
scanf("%d%d%d%d",&a,&b,&c,&d);
for(int i=1;i<=N;i++)
{
scanf("%d%d",&P[i].x,&P[i].y);
P[i].id=i;
}
P[0].x=0,P[0].y=0;P[0].id=0;
}
void set()
{
//cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
for(int i=1;i<=N;i++)
{
int x=P[i].x,y=P[i].y;
P[i].x=c*x-d*y;
P[i].y=b*y-a*x;
P[i].x*=(-1);P[i].y*=(-1);
}
}
int lowbit(int x)
{
return x&(-x);
}
void add(int x,int y)
{
//cout<<x<<" "<<y<<endl;
for(int i=x;i<=N+1;i+=lowbit(i)) tr[i]=max(tr[i],y);
}
int get(int x)
{
int ans=0;
for(int i=x;i>0;i-=lowbit(i)) ans=max(ans,tr[i]);
return ans;
}
void DP()
{
for(int i=0,j=0;i<=N;i++)
{
while(P[j].x<P[i].x)
{
//cout<<i<<" "<<j<<endl;
add(P[j].y,f[P[j].id]);
j++;
}
f[P[i].id]=get(P[i].y-1)+1;
}
}
bool cmp2(poi a,poi b)
{
if(a.y==b.y) return a.x<b.x;
return a.y<b.y;
}
void lisan()
{
sort(P,P+N+1,cmp2);
int cnt=1;
int Y[SIZEN]={0};
Y[0]=cnt;
for(int i=1;i<=N;i++)
{
if(P[i].y!=P[i-1].y) cnt++;
Y[i]=cnt;
}
for(int i=0;i<=N;i++) P[i].y=Y[i];
}
void work()
{
set();
//for(int i=0;i<=N;i++) cout<<P[i].x<<" "<<P[i].y<<" "<<P[i].id<<endl;
lisan();
sort(P,P+N+1,cmp);
//for(int i=0;i<=N;i++) cout<<P[i].x<<" "<<P[i].y<<" "<<P[i].id<<endl;
DP();
printf("%d",f[0]-1);
}
int main()
{
freopen("asm_second.in","r",stdin);
freopen("asm_second.out","w",stdout);
read();
work();
return 0;
}