传送门

我们把所有的直线按斜率从小到大排序,然后用单调栈维护

发现,如果当前直线与\(st[top-1]\)直线的交点的横坐标大于等于与\(st[top]\)的交点的横坐标,当前直线可以覆盖掉\(st[top]\)

这个可以画图理解一下

//minamoto
#include<bits/stdc++.h>
#define rint register int
using namespace std;
#define getc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
char buf[1<<21],*p1=buf,*p2=buf;
int read(){
int res,f=1;char ch;
while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
return res*f;
}
const int N=50005;
struct node{
int a,b,id;
inline bool operator <(const node &q)const{return a==q.a?b>q.b:a<q.a;}
}p[N];int n,st[N],top;
inline double solve(int i,int j){return (double)(p[i].b-p[j].b)/(p[j].a-p[i].a);}
int main(){
// freopen("testdata.in","r",stdin);
n=read();for(rint i=1;i<=n;++i)p[i].a=read(),p[i].b=read(),p[i].id=i;
sort(p+1,p+1+n),st[top=0]=1;
for(rint i=2;i<=n;++i){
if(p[i].a==p[i-1].a)continue;
while(top&&solve(st[top],i)<=solve(st[top-1],i))--top;
st[++top]=i;
}for(rint i=0;i<=top;++i)st[i]=p[st[i]].id;
sort(st,st+1+top);for(rint i=0;i<=top;++i)printf("%d ",st[i]);return 0;
}

P3194 [HNOI2008]水平可见直线的更多相关文章

  1. 【bzoj1007】[HNOI2008]水平可见直线

    1007: [HNOI2008]水平可见直线 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 5932  Solved: 2254[Submit][Sta ...

  2. bzoj 1007 [HNOI2008]水平可见直线(单调栈)

    1007: [HNOI2008]水平可见直线 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 5120  Solved: 1899[Submit][Sta ...

  3. BZOJ 1007 [HNOI2008]水平可见直线

    1007: [HNOI2008]水平可见直线 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 4453  Solved: 1636[Submit][Sta ...

  4. 1007: [HNOI2008]水平可见直线[维护下凸壳]

    1007: [HNOI2008]水平可见直线 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 7184  Solved: 2741[Submit][Sta ...

  5. 2018.07.03 BZOJ 1007: [HNOI2008]水平可见直线(简单计算几何)

    1007: [HNOI2008]水平可见直线 Time Limit: 1 Sec Memory Limit: 162 MB Description 在xoy直角坐标平面上有n条直线L1,L2,-Ln, ...

  6. BZOJ 1007 [HNOI2008]水平可见直线 (栈)

    1007: [HNOI2008]水平可见直线 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 7940  Solved: 3030[Submit][Sta ...

  7. BZOJ 1007: [HNOI2008]水平可见直线 栈/计算几何

    1007: [HNOI2008]水平可见直线 Time Limit: 1 Sec  Memory Limit: 162 MB 题目连接 http://www.lydsy.com/JudgeOnline ...

  8. 【BZOJ1007】[HNOI2008]水平可见直线 半平面交

    [BZOJ1007][HNOI2008]水平可见直线 Description 在xoy直角坐标平面上有n条直线L1,L2,...Ln,若在y值为正无穷大处往下看,能见到Li的某个子线段,则称Li为可见 ...

  9. BZOJ 1007: [HNOI2008]水平可见直线 平面直线

    1007: [HNOI2008]水平可见直线 Description 在xoy直角坐标平面上有n条直线L1,L2,...Ln,若在y值为正无穷大处往下看,能见到Li的某个子线段,则称Li为可见的,否则 ...

随机推荐

  1. libevent reference Mannual I

    FYI:http://www.wangafu.net/~nickm/libevent-book/ This lib is a integral of asynchronous IO. we shoul ...

  2. ubuntu中mysql忘记密码如何修改

    1.在终端进入安装目录下:cd /etc/mysql 2.sudo cat debian.cnf 输入密码 3用如下图用户和密码登录 4.进入mysql use mysql 5.使用describe ...

  3. linux cut-连接文件并打印到标准输出设备上

    博主推荐:获取更多 linux文件内容查看命令 收藏:linux命令大全 cut命令用来显示行中的指定部分,删除文件中指定字段.cut经常用来显示文件的内容,类似于下的type命令. 说明:该命令有两 ...

  4. mysql连接错误解决(ERROR 2049 (HY000): Connection using old (pre-4.1.1) authentication protocol ref used (client option 'secure_auth' enabled))

    当使用mysql的新版本是,连接老版本的mysql,就会有可能报: ERROR 2049 (HY000): Connection using old (pre-4.1.1) authenticatio ...

  5. pandas处理各类表格数据

    经常遇到Python读取excel和csv还有其他各种文件的内容.json还有web端的读取还是比较简单,但是excel和csv的读写是很麻烦.这里记录了pandas库提供的方法来实现文本内容和Dat ...

  6. hdu 1166敌兵布阵(线段树入门题)

    >>点击进入原题测试<< 思路:这两天在学线段树,这个题直接手敲一下线段树就行了,都没有用上懒人标记.入门题 cin,cout会超时,记得加std::ios::sync_wit ...

  7. HDU - 6446 Tree and Permutation

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6446 本题是一个树上的问题——DFS. 一棵N个结点的树,其结点为1~N.树具有N-1条边,每一条边具有 ...

  8. 抽象类和接口有什么区别---https://blog.csdn.net/csdn_aiyang/article/details/71171886

    https://blog.csdn.net/csdn_aiyang/article/details/71171886 概念]   抽象类.具体类是相对的,并非绝对的.抽象是一种概念性名词,具体是一种可 ...

  9. excel 2003 默认保存后出现超级连接解决方法

    在excel 2003 中当选中某个单元格然后拷贝出来后发现总是出现超级连接,每次都要取消下很是麻烦 . 于是经过研究找到解决方法,真是累的我够呛 ,先将方法介绍给大家. 工具---自动更正选项--- ...

  10. [luoguP2045] 方格取数加强版(最小费用最大流)

    传送门 水题 ——代码 #include <queue> #include <cstdio> #include <cstring> #include <ios ...