#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
#define INF 0x7f7f7f7f
#define MAXN (100000+5)
struct tnode{
double ti;
bool LR;
bool operator <(const tnode &a)const{
return ti<a.ti || (ti==a.ti && LR > a.LR);
}
};
int w, h, n, tn;
tnode times[MAXN*2];
void update(int xy, int ab, int wh, double &L, double &R){
if(!ab){
if(xy <= 0 || xy >= wh) R = L-1;
}else if(ab > 0){
L = max(L, -(double)xy/ab);
R = min(R,(double)(wh-xy)/ab);
}else{
L = max(L, (double)(wh-xy)/ab);
R = min(R, -(double)xy/ab);
}
}
int main(){
int T;
scanf("%d", &T);
while(T--){
scanf("%d%d%d", &w, &h, &n);
tn = 0;
for(int i = 0; i < n; i++){
int x, y, a, b;
double L = 0, R = 0.1*INF;
scanf("%d%d%d%d", &x, &y, &a, &b);
update(x, a, w, L, R);
update(y, b, h, L, R);
if(L < R){
times[tn++] = (tnode){L, 0};
times[tn++] = (tnode){R, 1};
}
}
sort(times, times+tn);
int cnt = 0, ans = 0;
for(int i = 0; i < tn; i++){
tnode now = times[i];
if(!now.LR) ans = max(ans, ++cnt);
else cnt--;
}
printf("%d\n", ans);
}
return 0;
}
uva 11549
最新推荐文章于 2020-01-09 23:13:03 发布