拿个单调队列维护
最后pop出来的就是它的左儿子
现在还在的,它是他的右儿子
int build() {
int S[N];
for(int i=1; i<=n; ++i) {
while(top && T[S[top]].val < T[i].val)
T[i].son[0]=S[top], --top;
if(top) T[S[top]].son[1]=i;
S[++top]=i;
}
top=0;
return S[1];
}
拿个单调队列维护
最后pop出来的就是它的左儿子
现在还在的,它是他的右儿子
int build() {
int S[N];
for(int i=1; i<=n; ++i) {
while(top && T[S[top]].val < T[i].val)
T[i].son[0]=S[top], --top;
if(top) T[S[top]].son[1]=i;
S[++top]=i;
}
top=0;
return S[1];
}