题目

传送门:QWQ

分析

扫描线搞一搞。

按左端点排序,左端点相同时按右端点排序。

如果是左端点就$ cnt++ $,否则$ cnt-- $

统计一下$ Max $就行了

代码

#include <bits/stdc++.h>
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;
}
else if(a>0){
L=max(L,-(double)x/a);
R=min(R,double(w-x)/a);
}
else{
L=max(L,(double)(w-x)/a);
R=min(R,-(double)x/a);
}
}
const int maxn=100010;
struct Event{
double x; int type;
bool operator < (const Event& a) const{
return x<a.x || (x==a.x&&type>a.type);
}
}events[maxn*2]; int main(){
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(R>L){
events[e++]=(Event){L,0};
events[e++]=(Event){R,1};
}
}
sort(events,events+e);
int cnt=0, ans=0;
for(int i=0;i<e;i++){
if(events[i].type==0) ans=max(ans,++cnt);
else --cnt;
}
printf("%d\n",ans);
}
return 0;
}

【UVALive】3905 Meteor(扫描线)的更多相关文章

  1. UVaLive 3905 Meteor (扫描线)

    题意:给定上一个矩形照相机和 n 个流星,问你照相机最多能拍到多少个流星. 析:直接看,似乎很难解决,我们换一个思路,我们认为流星的轨迹就没有用的,我们可以记录每个流星每个流星在照相机中出现的时间段, ...

  2. LA 3905 Meteor 扫描线

    The famous Korean internet company nhn has provided an internet-based photo service which allows The ...

  3. 【UVALive 3905】BUPT 2015 newbie practice #2 div2-D-3905 - Meteor

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102419#problem/D The famous Korean internet co ...

  4. 3905 - Meteor

    The famous Korean internet company nhn has provided an internet-based photo service which allows The ...

  5. LA 3905 Meteor

    给出一些点的初始位置(x, y)及速度(a, b)和一个矩形框,求能同时出现在矩形框内部的点数的最大值. 把每个点进出矩形的时刻分别看做一个事件,则每个点可能对应两个事件,进入事件和离开事件. 按这些 ...

  6. ACM计算几何题目推荐

    //第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面 ...

  7. 【转换模型+扫描线】【UVA1398】Meteor

    The famous Korean internet company nhn has provided an internet-based photo service which allows The ...

  8. UVALive 4221 Walk in the Park 扫描线

    Walk in the Park 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemi ...

  9. 扫描线 - UVALive - 6864 Strange Antennas

    Strange Antennas Problem's Link: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=87213 M ...

随机推荐

  1. flask 文件的上传下载和excel操作

    文件的下载 from flask import send_from_directory @excel_bp.route('/get_attachment/<path:filename>') ...

  2. losetup命令

    Linux losetup命令用于设置循环设备. 循环设备可把文件虚拟成区块设备,籍以模拟整个文件系统,让用户得以将其视为硬盘驱动器,光驱或软驱等设备,并挂入当作目录来使用. 语法 losetup [ ...

  3. CUDA Samples: Dot Product

    以下CUDA sample是分别用C++和CUDA实现的两个非常大的向量实现点积操作,并对其中使用到的CUDA函数进行了解说,各个文件内容如下: common.hpp: #ifndef FBC_CUD ...

  4. 数据链路层、ARP/RARP、ICMP、ping和traceroute

    互联网基础:   数据链路层:RFC文档:894/1042/1340 为IP模块发送和接受IP数据报 为ARP模块发送ARP请求和接收ARP应答 为RARP模块发送RARP请求和接收RARP应答   ...

  5. css3公共样式

    温馨提示:一下css封装,建议按需使用,否则会造成很大的代码冗余,且很多样式会造成不符合预期的效果,建议合理使用 <a href="https://meyerweb.com/eric/ ...

  6. Jmter-Test Fragment、Include Controller和Module Controller

    Test Fragment--测试片段 The Test Fragment is used in conjunction with the Include Controller and Module ...

  7. HDU3853LOOPS (师傅逃亡系列•三)(基础概率DP)

    Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help her friend Madoka sa ...

  8. Linux系统下位(Ubuntu 11.04) 下安装配置 JDK 7安装步骤指导

    第一步:下载jdk下载内容为:jdk分为:jdk-7-linux-i586.tar.gzjdk-7u51-linux-x64.tar.gz(适合64位Linux操作系统) hadoop版本为:hado ...

  9. LeetCode 529. Minesweeper

    原题链接在这里:https://leetcode.com/problems/minesweeper/description/ 题目: Let's play the minesweeper game ( ...

  10. python-pycharm控制台输出带颜色

    python_控制台输出带颜色的文字方法   在python开发的过程中,经常会遇到需要打印各种信息.海量的信息堆砌在控制台中,就会导致信息都混在一起,降低了重要信息的可读性.这时候,如果能给重要的信 ...