LA3905

/*
File Name   :LA3905.cpp
Author      : erlingyier
Created Time: 2014年09月06日 星期六 07时59分24秒
*/
#include <stdio.h>
#include <string.h>
#include <set>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

void update(int x, int a, int w, double& L, double& R)
{
    if(a==0){
	if(x <= 0||x >= w)
	  R = L-1;//error;
    } else if(a > 0)
    {
	L = max(L, -(double)x/a);
	R = min(R, (double)(w - x)/a);
    } else if(a < 0)
    {
	L = max(L, (double)(w - x)/a);
	R = min(R, -(double)x/a);
    }
}

const int maxn = 100000 + 10;

struct Event{
    double x;
    int type;
    bool operator < (const Event& a) const {
	return x < a.x||(x == a.x && type > a.type);
    }
}events[2*maxn];

int main( int argc, const char* argv[] )
{
    int T;
    scanf("%d", &T);
    while(T--)
    {
	int w, h, n, e = 0;
	scanf("%d%d%d", &w, &h, &n);
	for(int i = 0; i < n; i++)
	{
	    int x, y, a, b;
	    scanf("%d%d%d%d", &x, &y, &a, &b);
	    double L = 0, R = 1e9;
	    update(x, a, w, L, R);
	    update(y, b, h, L, R);
	    if(L < R)
	    {
		events[e++] = (Event){L, 0};
		events[e++] = (Event){R, 1};
	    }
	}

	sort(events, events + e);

	int cnt = 0, ans = 0;
	for(int i = 0; i < n; i++)
	{
	    if(events[i].type == 0)
	      ans = max(ans, ++cnt);
	    else cnt--;
	}
    	printf("%d\n", ans);
    }
    	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值