https://vjudge.net/problem/UVALive-3905

计算出每个点在相框中的时间段,扫描线做即可

关键在如何快速计算每个点在相框中的时间段。对每个点进行运动分解,进入的时间L是x进入和y进入的最大,退出时间R是x退出和y退出的最小,画图看一下即可

画图同时可以发现不经过相框的时候会导致L >= R

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define abs(a) ((a) < 0 ? (-1 * (a)) : (a))
inline void swap(int &a, int &b)
{
int tmp = a;a = b;b = tmp;
}
inline void read(int &x)
{
x = ;char ch = getchar(), c = ch;
while(ch < '' || ch > '') c = ch, ch = getchar();
while(ch <= '' && ch >= '') x = x * + ch - '', ch = getchar();
if(c == '-') x = -x;
} const int INF = 0x3f3f3f3f;
const int MAXN = + ; int tt,w,h,n,x[MAXN],y[MAXN],a[MAXN],b[MAXN],flag[MAXN << ], cnt[MAXN << ], tot, t[MAXN << ], ans, tag; bool cmp(int a, int b)
{
return t[a] == t[b] ? flag[a] > flag[b] : t[a] < t[b];
} inline void update(int x, int a, int w, int &L, int &R)
{
if(a == )
{
if(x <= || x >= w) R = L - ;
}
else if(a > )
{
L = max(L, -x * / a);
R = min(R, (w - x) * / a);
}
else
{
L = max(L, (w - x) * / a);
R = min(R, -x * / a);
}
} int main()
{
read(tt);
for(;tt;--tt)
{
read(w), read(h), read(n);
for(register int i = ;i <= n;++ i) read(x[i]), read(y[i]), read(a[i]), read(b[i]);
tot = ;
for(register int i = ;i <= n;++ i)
{
int L = , R = INF;
update(x[i], a[i], w, L, R);
update(y[i], b[i], h, L, R);
if(L < R)
{
t[++tot] = L;flag[tot] = ;cnt[tot] = tot;
t[++tot] = R;flag[tot] = ;cnt[tot] = tot;
}
}
std::sort(cnt + , cnt + + tot, cmp);
ans = tag = ;
for(register int i = ;i <= tot;++ i)
{
if(flag[cnt[i]]) -- tag;
else ++ tag;
ans = max(ans, tag);
}
printf("%d\n", ans);
}
return ;
}

LA3905

LA3905 Meteor的更多相关文章

  1. 【译】Meteor 新手教程:在排行榜上添加新特性

    原文:http://danneu.com/posts/6-meteor-tutorial-for-fellow-noobs-adding-features-to-the-leaderboard-dem ...

  2. Using View and Data API with Meteor

    By Daniel Du I have been studying Meteor these days, and find that Meteor is really a mind-blowing f ...

  3. POJ 3669 Meteor Shower【BFS】

    POJ 3669 去看流星雨,不料流星掉下来会砸毁上下左右中五个点.每个流星掉下的位置和时间都不同,求能否活命,如果能活命,最短的逃跑时间是多少? 思路:对流星雨排序,然后将地图的每个点的值设为该点最 ...

  4. 如何在Meteor中使用npm模块?

    首先,请在AtmosphereJs上搜索有无相关的封装包.尽量采用已有的封装包,而不是自己封装. 有两种方法在项目中使用来自npm的模块. 封装为Meteor包并在项目中添加包.使用meteor cr ...

  5. windows下Meteor+AngularJS开发的坑

    有复杂的地方我再开贴记录,这里只记录容易解决的坑. 1. windows下手工增加smart package.直接将下载下来的包扔到meteor package中.记得将文件夹名字改得和smart.j ...

  6. Meteor + node-imap(nodejs) + mailparser(nodejs) 实现完整收发邮件

    版本信息: Meteor:windows MIS安装  0.6.4 node-imap:npm指定的0.8.0版,不是默认的0.7.x版. mailparser:npm安装0.3.6 以下是记录踩到的 ...

  7. 手工给Meteor增加smart package的方法

    windows下无法装mrt(Meteor的包管理工具).不过还好smart package本身也就只是一个文件夹而已,不需要在Meteor中注册什么东西.所以直接把smart package扔到me ...

  8. Meteor+AngularJS:超快速Web开发

        为了更好地描述Meteor和AngularJS为什么值得一谈,我先从个人角度来回顾一下这三年来WEB开发的变化:     三年前,我已经开始尝试前后端分离,后端使用php的轻量业务逻辑框架.但 ...

  9. 示例开发过程记录:meteor,react,apollo

    本示例记录一个开发过程: 1)参考 Meteor React TUTORIAL教程 https://www.meteor.com/tutorials/react/creating-an-app 2). ...

随机推荐

  1. pip的使用方法简介

    pip是Python包管理工具,它提供了对Python包的查找.下载.安装.卸载的功能 目前如果你在 python.org 下载最新版本的安装包,则是已经自带了该工具. 以下是pip常用命令 显示版本 ...

  2. Linux+QT4+我忙活半宿的结果

    一个简单的计算器,虽然很弱智,而且还不完善,但是通过它,我大致了解了一下QT的用法   QT真的很高级,已经近乎纯面向对象的了.   QString可以自己转化成多种类型,就这一点,就已经和C#差不多 ...

  3. java_日历类

    calendar是日历类,该类是抽象类不能被实例化 public class CalendarTest { /* 创建对象和方法的使用 */ public static void main(Strin ...

  4. AM历史消息及文件记录删除

    1.下载 folderclear.bat 文件 2.用编辑方式打开这个文件 3.对里面的参数做修改 4.这个批处理文件,保留了 完整的一个月的消息记录 (如 今天是 2017.3.15 ,那么 清除数 ...

  5. Rainbow的信号

    Rainbow的信号 有一串长度为n的数列,现在从中等概率选出l,r,如果l大于r,则交换,有三个询问 l~r间的数与和的数学期望 l~r间的数或和的数学期望 l~r间的数异或和的数学期望 对于100 ...

  6. LR回放webservice脚本报错------------mmdrv.exe应用程序错误(未解决)

    1.录制完成webservice脚本如下: 2.回放脚本,报错: 3.网上查看了一些解决办法,但都是没有起到作用.

  7. fiddler抓包工具遇到的问题-------502报错

    遇到的问题: 打开浏览器,输入本机的虚拟机地址的bugfree,出现无法连接的提示,具体是: [Fiddler] The connection to '192.168.211.128' failed. ...

  8. [JZOJ4648] 【NOIP2016提高A组模拟7.17】锦标赛

    题目 描述 题目大意 有nnn个人,你要确定一个出场序列.每次新上台的人就会和擂主打一架,胜利的人继续当擂主.题目给出两两之间打架胜利(失败)的概率. 问111选手坚持到最后的最大概率. 思考历程 看 ...

  9. echarts的使用——vue

    在vue的项目开发中,数据的可视化可以用echarts来实现,具体用法如下: (1)安装echarts,进入项目目录,执行如下命令,安装echarts: npm install echarts (2) ...

  10. 使用Ajax在HTML页面中局部刷新页面(左边菜单右边页面)

    转载自:https://blog.csdn.net/Cenmen_17714/article/details/80969008 index.html <a href="javascri ...