Need Help With a Segment Tree Problem : SPOJ MULTQ3

Правка en1, от flash_7, 2015-06-06 20:55:03

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?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский flash_7 2015-06-06 20:55:03 1143 Initial revision (published)