Problem Link : http://www.spoj.com/problems/MULTQ3/
I tried to solve the problem using two different logic.
- For the first one for both update & query when i'm getting the propagate value of parent node is not zero,i'm calculating the result for it and then adding those propagate value to its left & right child.Then i'm making its own propagate value to zero as i have already use it for that node.So for the query operation i'm just returning the valid result when i find a valid range.I got AC for these one.
- For the second one for update operation when i find a valid range then i update its propagate value and also update the result while returning.So for the query operation until i find a valid range i sum up all the propagate value and pass it as a carry value while calling.Then when i find a valid range then calculate the result using that carry value and return it.But i'm getting WA for these solution though the logic seems ok to me. Can anyone help me where i'm doing wrong?
- My AC Code : http://ideone.com/IApyMo
- My WA Code : http://ideone.com/7MaAlr