/*
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;
}
LA3905
最新推荐文章于 2022-03-22 14:25:07 发布