flash_7's blog

By flash_7, history, 10 years ago, In English

Problem Link : http://www.spoj.com/problems/MULTQ3/

I tried to solve the problem using two different logic.

  1. 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.
  2. 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?
  • Vote: I like it
  • +5
  • Vote: I do not like it

| Write comment?