笛卡尔树

笛卡尔树

用处

复建,连简单的数据结构都不记得了

笛卡尔树维护的是树最右边的一条链

常用于有限制条件下的求极值

代码

简单来说,对于小根堆形式的笛卡尔树,就是维护的增的单调栈

1
2
3
4
5
6
7
8

for(int i=1;i<=n;++i){
while(tp&&A[stk[tp]]>A[i])
L[i]=stk[tp--];
if(tp)
R[stk[tp]]=i;
stk[++tp]=i;
}

题目

不记得之前写过什么题了,有遇到再更新

  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.

扫一扫,分享到微信

微信分享二维码
  • Copyrights © 2015-2023 0375w