Replies: 60 comments 8 replies
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment has been hidden.
This comment has been hidden.
-
说几个问题: |
Beta Was this translation helpful? Give feedback.
-
蒟蒻我很想问个问题: |
Beta Was this translation helpful? Give feedback.
-
线段树的优化。。。 |
Beta Was this translation helpful? Give feedback.
-
@bluedone 权值线段树?其实n棵权值线段树组成了一棵主席树。可以查询区间第k小,或者排名之类的 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
关于区间修改的部分 if (b[p] && s != t) {
d[p * 2] += b[p] * (m - s + 1), d[p * 2 + 1] += b[p] * (t - m);
b[p * 2] += b[p], b[p * 2 + 1] += b[p];
b[p] = 0;
} 这个地方的 其次,在区间赋值的例子中,光靠判断 |
Beta Was this translation helpful? Give feedback.
-
@pot-code Hi,有没有兴趣开个 PR 订正正文内容( |
Beta Was this translation helpful? Give feedback.
-
权值线段树基本上就是统计数字的个数的线段树,他的叶节点是数字的个数而非某个具体的数字。简单应用可以查询整个数组的第k大,可持久化之后可以实现查询区间第k大 |
Beta Was this translation helpful? Give feedback.
-
数字的个数不是具体的数字? 您想表达“不是某个维护的量的值, 而是某个值在维护的这些量中出现的次数”吧。 其实我更喜欢“以数值为下标”这种说法,或者是”对 cnt(一个值的出现次数)数组建线段树“。 |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
-
对于维护区间大小为n的线段树而言,开2n大小的线段树完全够了。考虑到n可以被分解为完全二叉树部分(大小为2^k-1)和剩余部分(2^k>=r>0),而一个深度为k + 1的完全二叉树数组即可把这两部分全装下(大小为2^(k+1)-1)。如果我开2n的话,2n=2^(k+1)-2+2r>=2^(k+1)-1 |
Beta Was this translation helpful? Give feedback.
-
标签永久化的方法能不能用在的带有乘法标记与加法标记的线段树上面呢? |
Beta Was this translation helpful? Give feedback.
-
如果你是要实现区间修改为某一个值而不是加上某一个值的话 |
Beta Was this translation helpful? Give feedback.
-
懒标记的区间修改图画错了,[3,5]区间加5以后,根节点变成了75,不是60。 |
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
-
所以在python里加 |
Beta Was this translation helpful? Give feedback.
-
好像没有求最大值? |
Beta Was this translation helpful? Give feedback.
-
线段树的深度那里是log2 n向下取整吧: |
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
-
或者叫类st表树? |
Beta Was this translation helpful? Give feedback.
-
建树过程如何保证是完全二叉树? |
Beta Was this translation helpful? Give feedback.
-
这里的C++模板中的maintain函数不是下方lazy标记吗,应该是push_down吧,名字起错了吧 |
Beta Was this translation helpful? Give feedback.
-
https://oi-wiki.org/ds/seg/
Beta Was this translation helpful? Give feedback.
All reactions