首先题意中的有撤销操作,直接李超树肯定不行,题目允许离线,所以考虑线段树分治

所以问题就变成了求一次函数最大值

这不是李超树板子吗???

然后可以对每个节点都建立动态开点李超树,查询的时候直接从叶子节点跳到根节点就好了

但是直接这样做的话时空复杂度都是 \(O(n\log n\log V)\) 的,空降将近 1.2GB,会被直接卡掉

优化就是,只保留目前节点到根节点的节点的李超树(因为只有这些用得上),然后在 \(O(\log n)\) 个李超树中查询,空间复杂度就变成了 \(O(n\log V)\)。如果想跑得快一点儿的话可以把李超树可持久化,虽然说复杂度仍然是 \(O(n\log n\log V)\) 的。

不过我倒是可持久化了,感觉码量都差不多(

吐槽一下,为啥李超树的效率和维护凸包的效率差不多啊(

#include<algorithm>
#include<cstdio>
#include<vector>
typedef long long ll;
const int M=3e5+5,V=1e9;
const ll INF=0x7fffffffffffffff;
int n,tot,root,k[M],opt[M],t[M*50],chi[M*50][2];ll ans[M];
std::vector<int>id[M<<2];
struct line{
int k,b;
line(const int&x=0,const int&y=0):k(k),b(b){}
inline ll get(const int&x)const{
return 1ll*k*x+b;
}
}p[M];
inline void swap(int&a,int&b){
int c=a;a=b;b=c;
}
inline ll max(const ll&a,const ll&b){
return a>b?a:b;
}
int Modify(int u,int id,int L=0,int R=V*2){
if(!u)return t[++tot]=id,tot;
int mid=(1ll*L+R)*.5,now=++tot;
t[now]=t[u];chi[now][0]=chi[u][0];chi[now][1]=chi[u][1];
if(p[id].get(mid-V)>p[t[now]].get(mid-V))swap(id,t[now]);
if(p[t[now]].get(L-V)>p[id].get(L-V)&&p[t[now]].get(R-V)>p[id].get(R-V))return now;
if(p[id].get(L-V)>p[t[now]].get(L-V))return chi[now][0]=Modify(chi[u][0],id,L,mid),now;
else return chi[now][1]=Modify(chi[u][1],id,mid+1,R),now;
}
ll Query(int u,int x,int L=0,int R=V*2){
if(!u)return-INF;
if(L==R)return p[t[u]].get(x-V);
int mid=(1ll*L+R)*.5;
if(x<=mid)return max(p[t[u]].get(x-V),Query(chi[u][0],x,L,mid));
else return max(p[t[u]].get(x-V),Query(chi[u][1],x,mid+1,R));
}
void modify(int u,int d,int l,int r,int L=1,int R=n){
if(l>R||L>r)return;
if(l<=L&&R<=r)return id[u].push_back(d);
int mid=L+R>>1;
modify(u<<1,d,l,r,L,mid);modify(u<<1|1,d,l,r,mid+1,R);
}
void Solve(int u=1,int L=1,int R=n){
int lroot=root,ltot=tot;
for(int&L:id[u])root=Modify(root,L);
if(L<R){
int mid=L+R>>1;
Solve(u<<1,L,mid);Solve(u<<1|1,mid+1,R);
}
else if(opt[L]==3)ans[L]=root?Query(root,k[L]+V):-INF;
while(tot>ltot)chi[tot][0]=chi[tot][1]=t[tot]=0,--tot;root=lroot;
}
signed main(){
register int i;
scanf("%d",&n);
for(i=1;i<=n;++i){
scanf("%d",opt+i);
if(opt[i]==1)scanf("%d%d",&p[i].k,&p[i].b),k[i]=n;
if(opt[i]==2)scanf("%d",k+i),k[k[i]]=i;
if(opt[i]==3)scanf("%d",k+i);
}
for(i=1;i<=n;++i)if(opt[i]==1)modify(1,i,i,k[i]);
Solve();
for(i=1;i<=n;++i){
if(opt[i]==3){
if(ans[i]==-INF)printf("EMPTY SET\n");
else printf("%lld\n",ans[i]);
}
}
}

CF678F题解的更多相关文章

  1. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  2. noip2016十连测题解

    以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...

  3. BZOJ-2561-最小生成树 题解(最小割)

    2561: 最小生成树(题解) Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1628  Solved: 786 传送门:http://www.lyd ...

  4. Codeforces Round #353 (Div. 2) ABCDE 题解 python

    Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring P ...

  5. 哈尔滨理工大学ACM全国邀请赛(网络同步赛)题解

    题目链接 提交连接:http://acm-software.hrbust.edu.cn/problemset.php?page=5 1470-1482 只做出来四道比较水的题目,还需要加强中等题的训练 ...

  6. 2016ACM青岛区域赛题解

    A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Jav ...

  7. poj1399 hoj1037 Direct Visibility 题解 (宽搜)

    http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minec ...

  8. 网络流n题 题解

    学会了网络流,就经常闲的没事儿刷网络流--于是乎来一发题解. 1. COGS2093 花园的守护之神 题意:给定一个带权无向图,问至少删除多少条边才能使得s-t最短路的长度变长. 用Dijkstra或 ...

  9. CF100965C题解..

    求方程 \[ \begin{array}\\ \sum_{i=1}^n x_i & \equiv & a_1 \pmod{p} \\ \sum_{i=1}^n x_i^2 & ...

随机推荐

  1. golang 获取当月最后一天日期

    now := time.Now() year, month, day := now.Date() //fmt.Println(year, month, day) //2021 September 1 ...

  2. ssh中“Host key verification failed.“的解决方案

    SSH连接的时候Host key verification failed. ➜ ~ ssh root@192.168.1.88 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ...

  3. 生成静态库.a文件和动态库.so文件

    转载来源:https://www.cnblogs.com/hookjc/ 静态库 在linux环境中, 使用ar命令创建静态库文件.如下是命令的选项: d -----从指定的静态库文件中删除文件 m ...

  4. 使用MediaPlayer框架实现简单音乐播放器-陈棚

    该项目需要使用MediaPlayer框架,因此程序需要先为该项目添加MediaPalyer框架,并在上面控制器类的实现部分使用#import<MediaPlayer/MediaPlayer.h& ...

  5. MySQL数据库授权与索引

    MySQL数据库授权与索引 目录 MySQL数据库授权与索引 一.数据库用户授权 1. 授予权限 2. 查看权限 3. 删除权限 4. 全部权限(all privileges) 二.MySQL索引 1 ...

  6. docker基础——2.镜像管理

    1. Docker镜像的主要特点 (1) 采用分层构建机制. 最底层为bootfs,用于系统引导的文件系统,包括bootloader和kernel,容器启动后会被卸载以节约资源. 其上为rootfs, ...

  7. Puppeteer简介

    puppeteer常用API https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md Puppeteer是一个node库,他 ...

  8. 06.python语法入门--与用户交互、运算符

    与用户交互 输入 input    # python2与python3的区别        '''python3'''    # 将获取到的用户输入赋值给变量名res    res = input(' ...

  9. 期中架构&防火墙¥四表五链

    今日内容 架构图 包过滤防火墙 Iptables 新建虚拟机 内容详细 一.架构图 用户通过域名访问一个网站类比开车去饭店用餐 访问网站的流程 1.浏览器输入网站的域名(www.baidu.com), ...

  10. Solution -「LOJ #6053」简单的函数

    \(\mathcal{Description}\)   Link.   积性函数 \(f\) 满足 \(f(p^c)=p\oplus c~(p\in\mathbb P,c\in\mathbb N_+) ...