博客
关于我
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之主从复制
查看>>
MySQL之函数
查看>>
mysql之分组查询GROUP BY,HAVING
查看>>
mysql之分页查询
查看>>
Mysql之备份与恢复
查看>>
mysql之子查询
查看>>
MySQL之字符串函数
查看>>
mysql之常见函数
查看>>
Mysql之性能优化--索引的使用
查看>>
mysql之旅【第一篇】
查看>>
Mysql之索引选择及优化
查看>>
mysql之联合查询UNION
查看>>
mysql之连接查询,多表连接
查看>>
mysql乐观锁总结和实践 - 青葱岁月 - ITeye博客
查看>>
mysql也能注册到eureka_SpringCloud如何向Eureka中进行注册微服务-百度经验
查看>>
mysql乱码
查看>>
Mysql事务。开启事务、脏读、不可重复读、幻读、隔离级别
查看>>
MySQL事务与锁详解
查看>>
MySQL事务原理以及MVCC详解
查看>>
MySQL事务及其特性与锁机制
查看>>