求助大佬,,这为啥不对
  • 板块UVA1398 Meteor
  • 楼主Eternality
  • 当前回复0
  • 已保存回复0
  • 发布时间2022/10/25 08:35
  • 上次更新2023/10/27 06:02:32
查看原帖
求助大佬,,这为啥不对
736891
Eternality楼主2022/10/25 08:35
#include<bits/stdc++.h>
using namespace std;

const int N=1e5+10;
int q,n,tot;
double X,Y;
struct T 
{
	int x,y;
}t[N<<1];

bool cmp(T a,T b)
{
	if(a.x==b.x)return a.y>b.y;
	return a.x<b.x;
}

void pre(int id,double x,double y,double vx,double vy)
{
	double ru,chu;
	if(vx>0&&vy>0)
	{
		ru=max(0.0,max(-x/vx,-y/vy));
		chu=max(0.0,min((X-x)/vx,(Y-y)/vy));
	}
	if(vx>0&&vy<0)
	{
		ru=max(0.0,max(-x/vx,(Y-y)/vy));
		chu=max(0.0,min((X-x)/vx,-y/vy));
	}
	if(vx<0&&vy>0)
	{
		ru=max(0.0,max((X-x)/vx,-y/vy));
		chu=max(0.0,min(-x/vx,(Y-y)/vy));
	}
	if(vx<0&&vy>0)
	{
		ru=max(0.0,max((X-x)/vx,(Y-y)/vy));
		chu=max(0.0,min(-x/vx,-y/vy));
	}
	if(vx==0&&x>0&&x<X)
	{
		if(vy>0)
		{
			ru=max(0.0,-y/vy);
			chu=max(0.0,(Y-y)/vy);
		}else
		{
			ru=max(0.0,(Y-y)/vy);
			chu=max(0.0,-y/vy);
		}
	}
	if(vy==0&&y>0&&y<Y)
	{
		if(vx>0)
		{
			ru=max(0.0,-x/vx);
			chu=max(0.0,(X-x)/vx);
		}else
		{
			ru=max(0.0,(X-x)/vx);
			chu=max(0.0,-x/vx);
		}
	}
	if(ru==chu)return;
	t[++tot].x=ru;
	t[tot].y=1;
	t[++tot].x=chu;
	t[tot].y=2;
}

int main()
{
	scanf("%d",&q);
	while(q--)
	{
		tot=0;
		scanf("%lf%lf%d",&X,&Y,&n);
		for(int i=1;i<=n;i++)
		{
			int x,y,vx,vy;
			scanf("%d%d%d%d",&x,&y,&vx,&vy);
			pre(i,x*1.0,y*1.0,vx*1.0,vy*1.0);
		}
		sort(t+1,t+1+tot,cmp);
		int ans=0,maxx=0;
		for(int i=1;i<=tot;i++)
		{
			if(t[i].y==1)ans++;
			else ans--;
			maxx=max(maxx,ans);
		}
		cout<<maxx<<endl;
	}
	return 0;
}
2022/10/25 08:35
加载中...