参考我的题解(您为什么要边build边读入呢)
其实既然你把k的儿子设为2*k和2 *k+1,您就不用
用struct 记录lc和rc了
by Vocalise @ 2019-09-24 21:09:31
据观察,您的struct应该是没有锅的
by Vocalise @ 2019-09-24 21:11:09
一个较明显的错误
```cpp
ll Ask(ll l,ll r,ll x,ll y,ll k)
{
if(r < x || l > y)
return 0LL;
Update(k);
if(l >= x && r <= y)
return t[k].val;
ll mid = (l+r)>>1;
Update(k);
ll res = 0LL;
res = Ask(l,mid,x,y,2*k);//这里不加???
Update(k);
res += Ask(mid+1,r,x,y,2*k+1);
return res;
}
```
by misaka_八重樱 @ 2019-09-24 21:27:12
@[misaka_八重樱](/space/show?uid=148987) 加不加都一样啊,本来res=0,我只不过直接把左儿子的值赋了上去
by MaxAndFelix @ 2019-09-24 21:29:34
@[MaxAndFelix](/space/show?uid=104881) 好吧,我傻了,刚才还能调到正确答案,现在又不行了,我tcl
by misaka_八重樱 @ 2019-09-24 22:13:21
@[misaka_八重樱](/space/show?uid=148987) 那大佬你知道大概哪里有错误码?
by MaxAndFelix @ 2019-09-24 23:10:37
@[MaxAndFelix](/space/show?uid=104881) 我找到你了,zqy
by farines @ 2019-10-03 22:19:41
@[farines](/space/show?uid=166850) ???
by MaxAndFelix @ 2019-10-03 23:59:30