比赛 “Asm.Def战记之太平洋”杯 评测结果 AATWETTTEE
题目名称 Asm.Def的一秒 最终得分 20
用户昵称 slyterlins 运行时间 4.475 s
代码语言 C++ 内存使用 0.42 MiB
提交时间 2015-11-02 11:33:10
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
double n,m,a,b,c,d,na,nb,ans;
double xx[10005],yy[10005];
inline bool find(double xx,double yy){
//	cout<<a/b*xx+nb-na*(a/b)<<" "<<yy<<' '<<c/d*xx+nb-na*(a/b)<<endl;
    if(b==0&&d!=0)if(yy>nb&&yy<(c/d*xx+nb-na*(a/b))&&xx>na&&yy>nb)return 1;
	if(b!=0&&d!=0)
	if(yy>(a/b*xx+nb-na*(a/b))&&yy<(c/d*xx+nb-na*(a/b))&&xx>na&&yy>nb)return 1;
	else return 0;
}
inline bool find1(double xx,double yy){
	if(xx>na&&yy>nb)return 1;
	else return 0;
}
inline void dfs(double a,double b,double c){
	ans=max(ans,c);
	na=a;nb=b;
	for(int i=1;i<=n;i++){
//		cout<<find(xx[i],yy[i])<<endl;
		if(find(xx[i],yy[i]))
		{ 
			na=xx[i];nb=yy[i];
			dfs(xx[i],yy[i],c+1);
			na=a;nb=b;
		}
	}
}
inline void dfs1(double a,double b,double c){
	ans=max(ans,c);
	na=a;nb=b;
	for(int i=1;i<=n;i++){
		if(find1(xx[i],yy[i]))
		{ 
			na=xx[i];nb=yy[i];
			dfs1(xx[i],yy[i],c+1);
			na=a;nb=b;
		}
	}
}
int main(){
	freopen("asm_second.in","r",stdin);
    freopen("asm_second.out","w",stdout);
	cin>>n>>a>>b>>c>>d;
	double cc;if(d!=0&&a/b>c/d){cc=c;c=a;a=cc;cc=b;b=d;d=cc;}
    for(int i=1;i<=n;i++)cin>>xx[i]>>yy[i];
	if(a==0&&b==1&&c==1&&d==0){
		dfs1(0,0,0);
		cout<<ans;
		return 0;
	}
    dfs(0,0,0);
 	cout<<ans;
 	return 0;
}