cout<<bit.query(1,1,1,n,n,n)-bit.query(x1,y1,z1,x2,y2,z2)<<’\n’; //this gives WA but why?
but
cout<<bit.query(1,1,1,N-1,N-1,N-1)-bit.query(x1,y1,z1,x2,y2,z2)<<’\n’; //this gives AC
why is these give diff answer?
Doubt in query part of BIT
You are using 1-based fenwick tree, query should be bit.query(1,1,1,n+1,n+1,n+1). This will work.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.