求助替罪羊树
查看原帖
求助替罪羊树
28392
zrzring楼主2020/8/5 09:08

注释里的能AC,没注释的部分AC不了,请问为什么替罪羊树不能这么写,如果可以这种思路写的话应该怎么改呢(或者提供一份hack这种写法的思路也可以鸭)

int pre(int t) {
    //return query(getrk(t) - 1);
    int x = rt, res = 0;
    while (x) {
        if (val[x] >= t) x = ls;
        else {if (cnt[x]) res = val[x]; x = rs;}
    }
    return res;
}
int suf(int t) {
    //return query(getrk(t + 1));
    int x = rt, res = 0;
    while (x) {
        if (val[x] <= t) x = rs;
        else {if (cnt[x]) res = val[x]; x = ls;}
    }
    return res;
}
2020/8/5 09:08
加载中...