水平可见直线,半平面交??什么鬼,被dalao低飞。我只是用一个小小的数单调队列做出来的。具体就是通过维护一个上升的斜率单调队列然后不停单调就做出来了。神奇的单调队列,说实话我忘了怎么打模版了。#include<map> #include<queue> #include<cmath> #include<cctype> #include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define qread(x) x=read() #define mes(x,y) memset(x,y,sizeof(x)) #define mpy(x,y) memcpy(x,y,sizeof(x)) #define Maxn 50000 #define INF 2147483647 #define eps 1e-6 inline int read(){ char ch=getchar(); int f=1,x=0; while(!(ch>='0'&&ch<='9')){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+(ch-'0');ch=getchar();} return x*f; } struct Pfun{ int x;double k,b; }P[Maxn+1]; int cmp(const Pfun a,const Pfun b){ return (a.k<b.k||(a.k==b.k&&a.b<b.b)); } int n,top,sta[Maxn+1],ans[Maxn+1]; double Pnode(int x,int y){ return (P[y].b-P[x].b)/(P[x].k-P[y].k); } int main(){ qread(n); for(int i=1;i<=n;i++){ qread(P[i].k);qread(P[i].b); P[i].x=i; } std::sort(P+1,P+n+1,cmp); top=0; for(int i=1;i<=n;i++){ while(top>0&&P[i].k-P[sta[top]].k<eps)top--; while(top>1&&Pnode(sta[top-1],sta[top])>=Pnode(sta[top],i))top--; sta[++top]=i; } for(int i=1;i<=top;i++)ans[i]=P[sta[i]].x; std::sort(ans+1,ans+top+1); for(int i=1;i<=top;i++)printf("%d ",ans[i]);printf("\n"); return 0; }
查看原文:http://hz2016.tk/blog/?p=63
[HNOI2008]水平可见直线
最新推荐文章于 2020-01-31 12:59:20 发布