随笔分类 - 树——splay
摘要:这道题维护区间极差的最小值 只有长度为二的区间有贡献 这个可以尝试画一下 自己想想 这样之后维护的值有 区间最小值 区间最大值 以及区间内长度为二的区间差的最小值 区间大小 点本身的值。 注意要看你维护的区间差在区间左点还是右点 这在查询min的时候很重要 剩下的自己看把 代码不算长的了 虽然有点慢
阅读全文
摘要:这道题 首先 因为他求的是当前点到根节点的路径和 我们可以将题目转换为括号序列的写法 将点拆为左括号以及右括号 左括号为正 右括号为负 这样题目就变为了求前缀和了 如果一个点是这个点的子树 那么他的左右括号就一定包含在所求区间里 会被抵消掉而不影响结果。 这样我们可以利用dfs序建树 操作为区间加
阅读全文
摘要:#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int M=100055,inf=1000000000; int read(){ int ans=0,f=1,c=getchar();
阅读全文
摘要:#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int M=100055,inf=0x3f3f3f3f; int read(){ int ans=0,f=1,c=getchar();
阅读全文
摘要:#include<cstdio> #include<cstring> #include<algorithm> #include<queue> using namespace std; const int M=1000555,inf=1000000000; int read(){ int ans=0,
阅读全文
摘要:#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int read(){ int ans=0,f=1,c=getchar(); while(c<'0'||c>'9'){if(c=='-') f=-1
阅读全文

浙公网安备 33010602011771号