uva 11549

来源:互联网 发布:网络直播用户规模 编辑:程序博客网 时间:2024/06/05 19:03
#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;}


0 0
原创粉丝点击