这个题要想办法把它的每个流星在相机里出现的时段算出。把进入的时间和离开的时间存入event。sort之后,从头扫描维护。若进入一个那么流星个数加一,若离开一个,个数减一。不用算出是谁进入谁离开。但是若在一个时间,有流星同时离开和进入,需要好好考虑一下。因为是同时发生,所以如果维护方法有误,可能翻车。
/**
PROG:milk2
LANG:C++
ID:DickensTone
**/
#include<iostream>
#include<fstream>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 1e5 * 2 + 5;
struct events
{
double x;
int type;
bool operator <(const events &a) const {
return x < a.x || (x == a.x && type > a.type);
}
}event[maxn];
void update(int x, int w, int a, double &L, double &R)
{
if(a == 0)
{
if(x <= 0 || x >= w) R = L - 1;
}
else if(a < 0)
{
L = max(L, (double)(w - x) / a);
R = min(R, -(double)x / a);
}
else
{
L = max(L, -(double)x / a);
R = min(R, double(w - x) / a);
}
}
int main()
{
//freopen("milk2.in", "r", stdin);
//freopen("milk2.out", "w", stdout);
int T;
scanf("%d", &T);
while(T--)
{
int w, h, cnt = 0;
scanf("%d%d", &w, &h);
int n, x, y, a, b;
scanf("%d", &n);
for(int kase = 0; kase < n; kase++)
{
scanf("%d%d%d%d", &x, &y, &a, &b);
double L = 0, R = 1e9;
update(x, w, a, L, R);
update(y, h, b, L, R);
if(R > L)
{
event[cnt++] = (events){L, 0};
event[cnt++] = (events){R, 1};
}
}
sort(event, event + cnt);
int e = 0, ans = 0;
for(int i = 0; i < cnt; i++)
{
if(event[i].type == 0) ans = max(ans, ++e);
else e--;
}
printf("%d\n", ans);
}
return 0;
}