博客
关于我
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/

你可能感兴趣的文章
NAS个人云存储服务器搭建
查看>>
NAS服务器有哪些优势
查看>>
NAT PAT故障排除实战指南:从原理到技巧的深度探索
查看>>
nat 网卡间数据包转发_你是不是从来没有了解过光纤网卡,它跟普通网卡有什么区别?...
查看>>
NAT-DDNS内网穿透技术,快解析DDNS的优势
查看>>
NAT-DDNS内网穿透技术,快解析DDNS的优势
查看>>
NAT-DDNS内网穿透技术,解决动态域名解析难题
查看>>
natapp搭建外网服务器
查看>>
NativePHP:使用PHP构建跨平台桌面应用的新框架
查看>>
nativescript(angular2)——ListView组件
查看>>
NativeWindow_01
查看>>
Native方式运行Fabric(非Docker方式)
查看>>
Nature | 电子学“超构器件”, 从零基础到精通,收藏这篇就够了!
查看>>
Nature和Science同时报道,新疆出土四千年前遗骸完成DNA测序,证实并非移民而是土著...
查看>>
Nature封面:只低一毫米,时间也会变慢!叶军团队首次在毫米尺度验证广义相对论...
查看>>
Nat、端口映射、内网穿透有什么区别?
查看>>
Nat、端口映射、内网穿透有什么区别?
查看>>
nat打洞原理和实现
查看>>
NAT技术
查看>>
NAT模式/路由模式/全路由模式 (转)
查看>>