博客
关于我
codeforces 543E. Listening to Music
阅读量:252 次
发布时间:2019-03-01

本文共 1222 字,大约阅读时间需要 4 分钟。

每个线段树节点需要保存四个值,ls,rs,min,tag
由于空间不够 所以把他们压缩成一个unsinged long long
t[x] = (ls * N + rs) * T + val + tag
t[x] % T 即可得到val + tag, ls = t[x] / T / N, rs = t[x] / T % N
进行标记永久化过后可以用左右儿子的值解出自己的val,再解出tag
然后就卡着内存过去了
黑科技简直可怕
code(爆空间的)

#include
#include
#include
#include
#include
#include
using namespace std;vector
vec[200010];struct trnode{ int lc,rc,c,u;}tr[3800010];int tot=0,root[200010];void update(int &x,int l,int r,int fl,int fr,int c){ tr[++tot]=tr[x];x=tot; if(l==fl&&r==fr) { tr[x].c+=c;tr[x].u+=c;return;} int mid=(l+r)/2; if(fr<=mid) update(tr[x].lc,l,mid,fl,fr,c); else if(fl>mid) update(tr[x].rc,mid+1,r,fl,fr,c); else update(tr[x].lc,l,mid,fl,mid,c),update(tr[x].rc,mid+1,r,mid+1,fr,c); tr[x].c=min(tr[tr[x].lc].c,tr[tr[x].rc].c)+tr[x].u;}int findans(int x,int l,int r,int fl,int fr){ if(!x) return 0; if(l==fl&&r==fr) return tr[x].c; int mid=(l+r)/2; if(fr<=mid) return findans(tr[x].lc,l,mid,fl,fr)+tr[x].u; if(fl>mid) return findans(tr[x].rc,mid+1,r,fl,fr)+tr[x].u; return min(findans(tr[x].lc,l,mid,fl,mid),findans(tr[x].rc,mid+1,r,mid+1,fr))+tr[x].u;}int n,m,cnt=0,b[200010];struct node{ int a,num;}a[200010];bool cmp(node a,node b) { return a.a

转载地址:http://kmza.baihongyu.com/

你可能感兴趣的文章
Mysql索引(4):索引语法
查看>>
mysql级联删除_Mysql笔记系列,DQL基础复习,Mysql的约束与范式
查看>>
mysql练习语句
查看>>
mysql经常使用命令
查看>>
MySQL经常使用技巧
查看>>
mysql给账号授权相关功能 | 表、视图等
查看>>
MySQL缓存使用率超过80%的解决方法
查看>>
Mysql缓存调优的基本知识(附Demo)
查看>>
mysql编写存储过程
查看>>
mysql网站打开慢问题排查&数据库优化
查看>>
mysql网络部分代码
查看>>
mysql联合索引 where_mysql联合索引与Where子句优化浅析
查看>>
mysql联合索引的最左前缀匹配原则
查看>>
MySQL聚簇索引
查看>>
mysql自动化同步校验_Shell: 分享MySQL数据同步+主从复制自动化脚本_20190313_七侠镇莫尛貝...
查看>>
Mysql自增id理解
查看>>
mysql自增id超大问题查询
查看>>
MySQL自定义变量?学不废不收费
查看>>
MySQL自带information_schema数据库使用
查看>>
MySQL获取分组后的TOP 1和TOP N记录
查看>>