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. JVM实战

    一.内存溢出 虚拟机栈和本地方法栈溢出:-Xss256k package com.jedis; import java.util.LinkedList; import java.util.List; ...

  2. JS流程控制语句 多重判断满足你各种需求 要在多组语句中选择一组来执行,使用if..else嵌套语句。

    多重判断(if..else嵌套语句) 要在多组语句中选择一组来执行,使用if..else嵌套语句. 语法: if(条件1) { 条件1成立时执行的代码} else if(条件2) { 条件2成立时执行 ...

  3. opencv编译:The CXX compiler identification is unknown The C compiler identification is unknown

    opencv编译:The CXX compiler identification is unknown The C compiler identification is unknown 解决方法: F ...

  4. sort的cmp函数

    sort的cmp函数只能写return a>b;或者return a<b;

  5. 阿里巴巴大数据产品最新特性介绍--机器学习PAI

    以下内容根据演讲视频以及PPT整理而成. 本次分享主要围绕以下五个方面: PAI产品简介 自定义算法上传 数加智能生态市场 AutoML2.0自动调参 AutoLearning自动学习 一.PAI产品 ...

  6. iPhone开发关于UDID和UUID的一些理解

    一.UDID(Unique Device Identifier)  UDID是Unique Device Identifier的缩写,中文意思是设备唯一标识.  在很多需要限制一台设备一个账号的应用中 ...

  7. mysql TO_DAYS()

    mysql TO_DAYS(date) 函数 TO_DAYS(date) 给定一个日期date, 返回一个天数 (从年份0开始的天数 ). mysql> SELECT TO_DAYS(95050 ...

  8. atoi和itoa函数的实现方法

    atoi的实现: #include<iostream> using namespace std; int atio1(char *s) { int sign=1,num=0; if(*s= ...

  9. StringBuffer清空

    转载自:http://blog.sina.com.cn/s/blog_56fd58ab0100qfcz.html 在开发程序的时候,经常使用StringBuffer来进行字符串的拼接.如果在循环中来反 ...

  10. leetcode 854. K-Similar Strings

    给定两个字符串, 判断最少经过多少次swap 可以使得 两个字符串一致, 首先类似的问题 是存在一个 underlying graph 的. 每一个字母都对应着一个节点,两个字符串的不一致表示为图上的 ...