Uva-Live 3905-Meteor
来源:互联网 发布:傲飞数据整合工具 编辑:程序博客网 时间:2024/05/16 18:59
要求求出最多能看到多少流行,计算流行进入和出去的时间,然后排序遍历一次即可。
代码:
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;const int maxn=1e6;int w,h,n,e;struct node{ double t; int type; bool operator < (const node &a) const {return t==a.t?type>a.type:t<a.t; }}eve[maxn];void update(int x,int v,int w,double &L,double &R){ if(v==0) {if(x<=0||x>=w) R=L-1; } else if(v>0) {L=max(L,-(double)x/v);R=min(R,(double)(w-x)/v); } else {L=max(L,(double)(w-x)/v);R=min(R,-(double)x/v); }}int main(){ int cas; scanf("%d",&cas); while(cas--) {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=1e8; update(x,a,w,L,R); update(y,b,h,L,R); if(R>L) {eve[e++]=(node){L,0};eve[e++]=(node){R,1}; }}sort(eve,eve+e);int ans=0,cnt=0;for(int i=0;i<e;i++){ if(eve[i].type==0)ans=max(ans,++cnt); elsecnt--;}printf("%d\n",ans); } return 0;}
- Uva-Live 3905-Meteor
- Live Archive 3905 Meteor
- UVa live 3905 扫描线
- uva 1398 - Meteor
- uva 1398 - Meteor
- UVA 1398 - Meteor
- UVA 1398 - Meteor
- UVA之1398 - Meteor
- UVA 1398 Meteor
- Uva---1398Meteor
- UVA - 1398 Meteor
- 3905 - Meteor
- Meteor Live Template 定义几个快捷键
- uva 1398 - Meteor 模拟 99
- uva 1398 - Meteor(贪心)
- UVA 1398 Meteor(扫描线)
- Uva-Live Archive3902-Network
- UVA live 2678 - Subsequence
- Redis源码学习之【暂停说明】
- VC++ 6.0资源释放源码
- c++中可以对类中私有成员中的静态变量初始化吗?
- Android Ams浅析
- url为onclick事件时报tree未定义解决方法
- Uva-Live 3905-Meteor
- Hudson安装、配置
- 自己动手写搜索引擎(常搜吧历程七#解析文档之WORD#)(Java、Lucene、hadoop)
- 开源工具-hostsPlus
- 取余与位运算
- structs2 工作原理
- Ubuntu12.10 安装ATI显卡驱动
- Apache Drill: 大数据集互动分析的分布式框架
- 一些DLL的运行机制