1

I'm getting incorrect results for problem HORRIBLE

Here is my code : http://ideone.com/1Yb3yp

node query(int root,int l_most,int r_most,int l,int r)
{
  if(l_most >= l && r_most <= r)
    return tree[root];
  int l_child = (root<<1) , r_child = l_child + 1,mid = (l_most + r_most )>>1;
  node left=node(),right = node();
  if(l<=mid)
    left = query(l_child,l_most,mid,l,r);
  if(r>mid)
    right = query(r_child,mid+1,r_most,l,r);;
  node temp = node();
  temp.merge(left,right);
  return temp;
}
OmG
  • 18,337
  • 10
  • 57
  • 90
wen_dy
  • 31
  • 7
  • What do you get and what were you expecting? And post a [SSCCE](http://sscce.org/) to let us check how the program behaves. – Adri C.S. Mar 26 '15 at 13:15
  • i think the update isn't working properly.. expecting `80 508` – wen_dy Mar 26 '15 at 14:28
  • @AdriC.S. couldn't figure out where i went wrong,..void create is used for update.. – wen_dy Mar 26 '15 at 15:09
  • @wen_dy you want a correct solution? I got AC using BIT...or do you want someone to help you debug your segment tree code? – shole May 04 '15 at 04:08

0 Answers0