NOIP 模拟 $18\; \rm 导弹袭击$
题解 \(by\;zj\varphi\)
一道凸包题
对于每个导弹,它的飞行时间就是 \(tim=\frac{A}{a_i}+\frac{B}{b_i}\) 我们设 \(x=\frac{1}{a_i},y=\frac{1}{b_i}\) 那么 \(tim=Ax+By\)
化简后 \(y=-\frac{A}{B}x+\frac{tim}{B}\) 我们要让斜率最小,那么维护一个下凸包,但斜率只能是负的,所以我们只要左下凸包
所以对于 \(A,B\) 排序,按 \(A\) 加入点,最后记得维护左下凸包,不要把超过范围的也算进去
Code
#include<bits/stdc++.h>
#define ri register signed
#define p(i) ++i
using namespace std;
namespace IO{
char buf[1<<21],*p1=buf,*p2=buf;
#define gc() p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++
template<typename T>inline void read(T &x) {
ri f=1;x=0;register char ch=gc();
while(ch<'0'||ch>'9') {if (ch=='-') f=0;ch=gc();}
while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+(ch^48);ch=gc();}
x=f?x:-x;
}
}
using IO::read;
namespace nanfeng{
#define FI FILE *IN
#define FO FILE *OUT
template<typename T>inline T cmax(T x,T y) {return x>y?x:y;}
template<typename T>inline T cmin(T x,T y) {return x>y?y:x;}
typedef double db;
static const int N=3e5+7;
int st[N],tp,pre[N],vis[N],n,mxa,mxb;
db tk[N];
struct node{int a,b,id;}mis[N];
inline int operator<(const node &n1,const node &n2) {return n1.a==n2.a?n1.b>n2.b:n1.a>n2.a;}//每个相同的 a 只有最大的 b 有用
inline db slope(node n1,node n2) {return ((db)n1.a*n2.a*(n2.b-n1.b))/((db)n1.b*n2.b*(n2.a-n1.a));}
inline int main() {
// FI=freopen("nanfeng.in","r",stdin);
// FO=freopen("nanfeng.out","w",stdout);
read(n);
for (ri i(1);i<=n;p(i)) read(mis[i].a),read(mis[i].b),mis[i].id=i;
sort(mis+1,mis+n+1);
for (ri i(1);i<=n;p(i)) if(mxb<mis[i].b) mxb=mis[i].b,mxa=mis[i].a;
st[p(tp)]=1;
for (ri i(2);mxa<=mis[i].a&&i<=n;p(i)) {//mxa 防止右凸包也算进去
if (mis[i].a==mis[st[tp]].a) {
if (mis[i].b==mis[st[tp]].b)
pre[mis[i].id]=pre[mis[st[tp]].id],pre[mis[st[tp]].id]=mis[i].id;
continue;
}
while(tp>1&&slope(mis[st[tp]],mis[i])<tk[st[tp]]) --tp;
tk[i]=slope(mis[st[tp]],mis[i]),st[p(tp)]=i;
}
while(tp)
for (ri i(mis[st[tp--]].id);i;i=pre[i]) vis[i]=1;
for (ri i(1);i<=n;p(i)) if (vis[i]) printf("%d ",i);
return 0;
}
}
int main() {return nanfeng::main();}