求助

P1253 扶苏的问题

sugawara @ 2023-10-18 14:01:34

code

记录


by dry_ @ 2023-10-19 21:17:24

不是自己说的不开long long见祖宗吗


by sugawara @ 2023-10-21 14:39:44

@tjtdrxxz ?!but不开ll也没啥大事


by dry_ @ 2023-10-21 20:45:58

我不开long long会WA几个点


by dry_ @ 2023-10-21 21:04:28

建议检查下push_up和push_down,我用我的查询函数发现输出好像要问题,push_up不要用递归,要设两个lazy push_down()和up写成形如下方的

if(tree[ind].addcheck)
    {
        tree[up1(ind)].add1 = tree[ind].add1;
        tree[up1(ind)].add2 = tree[ind].add2;
        tree[up2(ind)].add1 = tree[ind].add1;
        tree[up2(ind)].add2 = tree[ind].add2;
        tree[up1(ind)].num = tree[ind].add1 + tree[ind].add2;
        tree[up2(ind)].num = tree[ind].add1 + tree[ind].add2;
        tree[up1(ind)].addcheck = 1;
        tree[up2(ind)].addcheck = 1;
    }
    else
    {
        tree[up1(ind)].num += tree[ind].add2;
        tree[up2(ind)].num += tree[ind].add2;
        tree[up1(ind)].add2 += tree[ind].add2;
        tree[up2(ind)].add2 += tree[ind].add2;
    }
    tree[ind].addcheck = 0;
    tree[ind].add1 = 0;
    tree[ind].add2 = 0;

up1(ind)是i << 1; up2(ind)是i << 1 | 1; add1是操作一的lazy add2是操作二的lazy addcheck代表哪个操作


|