点击打开链接uva 1398
思路:扫描法
分析:
1 不难发现,流星的轨迹是没有用的,有意义的只是每个流星在照相机视野内出现的时间段
2 那么我们就可以通过去求出没个流星在矩形内的时间段,然后利用扫描法去求。
具体见刘汝佳<<训练指南46页>>
代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 100010;
struct Event{
double x;
int type;
bool operator<(const Event& rhs)const{
return x < rhs.x || x == rhs.x && type == 1;
}
};
Event events[MAXN*2];
//求时间段
void update(int x , int a , int w , double&left , double& right){
if(a == 0){
if(x <= 0 || x >= w)
right = left-1;
}
else if(a > 0){
left = max(left , -x*1.0/a);
right = min(right , (w-x)*1.0/a);
}
else{
left = max(left , (w-x)*1.0/a);
right = min(right , -x*1.0/a);
}
}
int main(){
int Case;
scanf("%d" , &Case);
while(Case--){
int w , h , n , pos = 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 left = 0 , right = 1e9;
update(x , a , w , left , right);//水平风向求时间段
update(y , b , h , left , right);//竖直方向求时间段
if(right > left){
events[pos++] = (Event){left , 0};//左端点事件
events[pos++] = (Event){right , 1};//右端点事件
}
}
int ans = 0;
int cnt = 0;
for(int i = 0 ; i < pos ; i++){
if(events[i].type == 0) //碰到左端点更新cnt和ans
ans = max(ans , ++cnt);
else
cnt--;
}
printf("%d\n" , ans);
}
return 0;
}
分享到:
相关推荐
前端项目-mini-meteor,选择MeteorJS的客户端组件
资源分类:Python库 所属语言:Python 资源全名:python-meteor-0.1.4.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
awesome-react-native-meteor, 一个"awesome" 类型规划的列表,如何使用本地和 Meteor的反应 出色的本机 Meteor一个"awesome"类型规划的列表,如何使用本地和 Meteor的反应。 基于这个基于的基于的Awesome响应,这是...
包含backend-meteor-jquery 和 backend-meteor-jquery-seed
包含backend-meteor-angular 和 backend-meteor-angular-seed
前端开源库-meteor-html-toolsMeteor HTML工具,空
前端开源库-meteor-random-window-crypto流星随机窗口加密,空
前端开源库-meteor-htmljsMeteor HTMLJS,空
heroku-buildpack-meteor, 用于 Meteor (meteor.com)的heroku buildpack 用于 Meteor的 buildpack用法% heroku create --buildpack https://github.com/jordansissel/heroku-buildpack-meteor.git
前端开源库-meteor-spacebars流星空格键,空
前端开源库-meteor-tracker流星跟踪器,空
前端开源库-meteor-observe-sequence流星观测序列,空
前端开源库-meteor-blaze流星火焰,空
前端开源库-meteor-apollo-accounts流星阿波罗帐户,流星帐户在图形库
前端开源库-meteor-reactive-object-map流星反应物地图,流星火焰模板的反应图助手
前端开源库-meteor-spacebars-compilerMeteor空格键编译器,空
安装yarn add react-native-meteor或者npm i --save react-native-meteor相容性说明从RN 0.26.0开始,您必须使用ws或wss协议连接到流星服务器。 http在Android上不起作用。 建议始终使用与您的RN版本兼容的最新版本...
前端开源库-meteor-mongo-id.zip
前端开源库-meteor-babelMeteor Babel,与Meteor一起使用的Babel包装包
前端开源库-meteor-core流星核,空