扫描线求助
查看原帖
扫描线求助
140694
NotTogawaButSakiko楼主2022/11/16 09:40

线段树不会了。。。

void update(int p, ll l, ll r, int w){ //加边
        //这里传的l,r表示实际坐标,区别于T[].l,r
        //if(X[T[p].r + 1] <= l || X[T[p].l] >= r)    return; //当前区间无交集
        cout << p << endl;
        if(X[T[p].l] >= l && X[T[p].r + 1] <= r){
            T[p].cnt += w;
            pushup(p);
            return;
        }
        ll mid = X[T[p].l] + X[T[p].r + 1] >> 1;
        if(l <= mid)    update(lc(p), l, r, w);
        if(mid < r)     update(rc(p), l, r, w);
        pushup(p);
    }
          
          

这样写的会RE。因为p会越界。

错误出在哪了?

2022/11/16 09:40
加载中...