题目大意:给定一个平面,维护下列操作:
1.插入一个向量
2.询问第l到r个插入的向量中与某个向量叉积的最大值
强制在线
首先答案一定在凸包上 而且如果y>0则在上凸包上 否则就在下凸包上
且答案在同一凸包上呈现单峰函数 满足三分性质
但是现在让我们维护某个区间内的凸包,因此我们可以使用线段树
由于凸包的合并是线性的,我们不能每插入一个点都路径维护一下
这个很好办嘛!反正包含未插入点的线段树节点一定不会被查询到,因此只有在当前插入的点是线段树节点的右端点时才合并凸包不就好了嘛!
然后查询时在对应凸包上三分即可
注意两个节点y值相等的情况。。。再也不敢乱写凸包了。。。
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define M 400400
using namespace std;
struct Point{
long long x,y;
Point() {}
Point(long long _,long long __):
x(_),y(__) {}
friend Point operator + (const Point &p1,const Point &p2)
{
return Point(p1.x+p2.x,p1.y+p2.y);
}
friend Point operator - (const Point &p1,const Point &p2)
{
return Point(p1.x-p2.x,p1.y-p2.y);
}
friend long l