题意:

给一些流星的初始位置和运动向量,给了相机的拍摄范围;问你最多能拍到多少颗流星;

思路:

将流星用出现在相机拍摄范围内的时间段表示;sort后在扫面端点更新最大值;

Ac代码:

#include <bits/stdc++.h>
/*
#include <vector>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>
*/
using namespace std;
#define For(i,j,n) for(int i=j;i<=n;i++)
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<''||CH>'';F= CH=='-',CH=getchar());
for(num=;CH>=''&&CH<='';num=num*+CH-'',CH=getchar());
F && (num=-num);
}
int stk[], tp;
template<class T> inline void print(T p) {
if(!p) { puts(""); return; }
while(p) stk[++ tp] = p%, p/=;
while(tp) putchar(stk[tp--] + '');
putchar('\n');
} const LL mod=1e9+;
const double PI=acos(-1.0);
const LL inf=1e18;
const int N=2e5+;
const int maxn=;
const double eps=1e-; double l,r;
struct Seg
{
double po;
int type;
}seg[*N];
int cmp(Seg x,Seg y)
{
if(x.po==y.po)return x.type<y.type;
return x.po<y.po;
}
void ope(double b,double s,double v)
{
if(v==)
{
if(b<=||b>=s)r=l-;
}
else if(v>)
{
l=max(l,-b/v);
r=min(r,(s-b)/v);
}
else
{
l=max(l,(s-b)/v);
r=min(r,-b/v);
}
}
int main()
{
int t;
read(t);
while(t--)
{
int n;
double w,h;
scanf("%lf%lf",&w,&h);
read(n);
int cnt=;
For(i,,n)
{
l=,r=;
double x,y,a,b;
scanf("%lf%lf%lf%lf",&x,&y,&a,&b);
ope(x,w,a);
ope(y,h,b);
if(r<=l)continue;
seg[++cnt].po=l;
seg[cnt].type=;
seg[++cnt].po=r;
seg[cnt].type=;
}
sort(seg+,seg+cnt+,cmp);
int ans=,num=;
For(i,,cnt)
{
if(seg[i].type)num++;
else num--;
ans=max(ans,num);
}
cout<<ans<<"\n";
}
return ;
}

LA-3905 (扫描线)的更多相关文章

  1. LA 3905 Meteor 扫描线

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

  2. LA 3905 Meteor

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

  3. 【UVALive】3905 Meteor(扫描线)

    题目 传送门:QWQ 分析 扫描线搞一搞. 按左端点排序,左端点相同时按右端点排序. 如果是左端点就$ cnt++ $,否则$ cnt-- $ 统计一下$ Max $就行了 代码 #include & ...

  4. UVaLive 3905 Meteor (扫描线)

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

  5. LA 3029 - City Game (简单扫描线)

    题目链接 题意:给一个m*n的矩阵, 其中一些格子是空地(F), 其他是障碍(R).找一个全部由F 组成的面积最大的子矩阵, 输出其面积乘以3的结果. 思路:如果用枚举的方法,时间复杂度是O(m^2 ...

  6. LA 4127 - The Sky is the Limit (离散化 扫描线 几何模板)

    题目链接 非原创 原创地址:http://blog.csdn.net/jingqi814/article/details/26117241 题意:输入n座山的信息(山的横坐标,高度,山底宽度),计算他 ...

  7. .Uva&LA部分题目代码

    1.LA 5694 Adding New Machine 关键词:数据结构,线段树,扫描线(FIFO) #include <algorithm> #include <cstdio&g ...

  8. bzoj1645 / P2061 [USACO07OPEN]城市的地平线City Horizon(扫描线)

    P2061 [USACO07OPEN]城市的地平线City Horizon 扫描线 扫描线简化版 流程(本题为例): 把一个矩形用两条线段(底端点的坐标,向上长度,添加$or$删除)表示,按横坐标排序 ...

  9. 【线段树 扫描线 二维数点】loj#6276. 果树

    路径计数转成二维数点很妙啊 题目描述 NiroBC 姐姐是个活泼的少女,她十分喜欢爬树,而她家门口正好有一棵果树,正好满足了她爬树的需求. 这颗果树有 $N$ 个节点,标号 $1 \ldots N$ ...

  10. [USACO18JAN] Lifeguards S (线段树:扫描线面积)

    扫描线裸题没什么好说的 注意空间不要开小了!!! #include <cstdio> #include <cstring> #include <algorithm> ...

随机推荐

  1. 查看mysql库中所有表的大小和记录数

    查看mysql库中所有表的大小和记录数 ,), 'MB') as total_size FROM information_schema.TABLES WHERE TABLE_SCHEMA='datab ...

  2. PC下ubuntu查找PC串口并加入用户组

    1. 查看ttyS0隶属的组:ls -l /dev/ttyS0  //发现隶属于dialout组 输出: crw-rw---- 1 root dialout 4, 64  9月  9 08:23 /d ...

  3. java通过反射获取bean字段注解@Column中的信息

    直接上代码吧: Field field; Field[] fields=clas.getDeclaredFields(); for (int i = 0; i <fields.length ; ...

  4. poi 读取excel row.getCell() 为null

    ##### getCell()为null 科目 余额 1 利息 1000 2 60 3 现金 10000 表格第一个单元为空时getCell()为null,直接使用会出现空指针异常

  5. Windows下部署多个Tomcat

    编辑bin/startup.bat SET JAVA_HOME=...(JDK所在路径) SET CATALINA_HOME=...(Tomcat解压的路径) 编辑server.xml文件 <! ...

  6. PR物料KFF弹出LOV - WHERE条件重写

    PROCEDURE event (event_name VARCHAR2)IS---- This procedure allows you to execute your code at specif ...

  7. 应用程序中的server错误,没有名称为“ServiceBehavior”的服务行为

    应用程序中的server错误,没有名称为"ServiceBehavior"的服务行为         今天在阅读"创建和使用Web服务"的相关内容,在浏览器中查 ...

  8. csu1527: Bounty Hunter

    Time Limit:5000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu Submit Status id=134 ...

  9. react 中的无状态函数式组件

    无状态函数式组件,顾名思义,无状态,也就是你无法使用State,也无法使用组件的生命周期方法,这就决定了函数组件都是展示性组件,接收Props,渲染DOM,而不关注其他逻辑. 其实无状态函数式组件也是 ...

  10. Effective C++ 条款15、16 在资源管理类中提供对原始资源的访问||成对使用new 与 delete要采取相同形式

    1.在资源管理类中提供对原始资源的访问     前几个条款很棒,它们是对抗资源泄露的壁垒,但很多APIs直接指向 资源,这个时候,我们需要直接访问原始资源.     这里,有两种方法解决上述问题,我们 ...