LA 3905 Meteor [扫描线]
来源:互联网 发布:caffe model zoo 编辑:程序博客网 时间:2024/05/21 07:07
蓝书中的扫描线裸题。
顺便作为计算几何练手。
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<set>#include<queue>#include<algorithm>#include<vector>#include<cstdlib>#include<cmath>#include<ctime>#include<stack>#define INF 2100000000#define ll long long#define clr(x) memset(x,0,sizeof(x))using namespace std;const int maxn = 1e5+20;void updata(int x,int a,int w,double &L,double &R){ if(a==0){ if(x<=0||x>=w)R=L-1; }else{ if(a>0){ L=max(L,-(double)x/a); R=min(R,(double)(w-x)/a); }else{ L=max(L,(double)(w-x)/a); R=min(R,-(double)x/a); } }}struct Event{ double x; int type; bool operator < (const Event &rhs)const{ return x<rhs.x||(x==rhs.x&&type>rhs.type); }};Event events[maxn<<1];int Ti,Wild_,high_,num,ech,xi_,ai_,yi_,bi_,ans,cnt;int main(){ scanf("%d",&Ti); while(Ti--){ scanf("%d%d%d",&Wild_,&high_,&num),ech=0,ans=0,cnt=0; for(int i=0;i<num;i++){ scanf("%d%d%d%d",&xi_,&yi_,&ai_,&bi_); double L=0,R=1e9; updata(xi_,ai_,Wild_,L,R); updata(yi_,bi_,high_,L,R); if(R>L){ events[ech++]=(Event){L,0}; events[ech++]=(Event){R,1}; } } sort(events,events+ech); for(int i=0;i<ech;i++){ if(events[i].type==0)ans=max(ans,++cnt); else --cnt; } cout<<ans<<endl; } return 0;}
话说我也是从这道题上面学习的struct的各种在当时看来灵活的用法。1年多了,再看这道提,感觉自己的进步还是很少呀。必须得努力了,现在放水已经考不过同班的同学了。
阅读全文
0 0
- LA 3905 Meteor 扫描线 -
- LA 3905 Meteor [扫描线]
- LA 3905 Meteor / 区间扫描
- LA 3905 Meteor (排序+扫描法)
- LA 3905(p45)----Meteor
- LA 3905(扫描线)
- UVALive 3905-Meteor-扫描线算法
- Uva1398--Meteor(扫描线)
- Seoul 2007 Meteor 流星 ,LA 3905
- LA3905-Meteor(扫描线)
- UVA 1398 Meteor(扫描线)
- 【转换模型+扫描线】【UVA1398】Meteor
- UVALive LA3905 Meteor (扫描线统计)
- LA 2678 Meteor (区间覆盖)
- LA 3695 Distant Galaxy(扫描线)
- LA 3695 Distant Galaxy 扫描线 -
- LA 3029 City Game [扫描线][DP]
- UVa 1398 Meteor 解题报告(扫描线)
- Kotlin学习之-5.13 代理属性
- JavaScript的正则表达式(一)
- 711(2)
- 6/23作业:类之间关系
- r语言神经网络
- LA 3905 Meteor [扫描线]
- Hadoop 集群搭建之一 CentOS7 安装
- 利用StringBuffer读写文件实例
- EA&UML日拱一卒-活动图::SendSignalAction
- DBA扁鹊
- POJ bfs+dfs之3083-Children of the Candy Corn
- python文件操作
- 【web前端自动化工作环境配置】6. 版本控制工具git与githup的区别与联系以及git的基本用法
- for循环遍历list集合组拼成字符串StringBuilder,及处理最后一个逗号