Azin_Ahamed's blog

By Azin_Ahamed, history, 3 months ago, In English

I'm trying to solve dynamic range minimum query(CSES).(Using Segment Tree) For updating, I am going from child to parent, eventually root.

//updating segment

void update(int st[],int idx)
{
	st[idx]=min(st[2*idx+1],st[2*idx+2]);
	if(idx==0)return;
	update(st,(int)((idx-1)/2));
}
//main part
   int arr[n];
   int hight=ceil(log2(n));
   int size=(1<<(hight+1))-1;
   int st[size]; //segment tree
   //both arr and st 0 based
   //pos->the index to be updated, newvalue->the updated value
    arr[pos]=newvalue;
    int idx=(1<<hight)-1+pos; st[idx]=newvalue;
    if(idx)
      update(st,(int)((idx-1)/2));

Note: I got ac by updating from parent to node recursively.But,getting wrong answer doing this way. Kindly help

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By Azin_Ahamed, history, 4 months ago, In English

I am stuck at 1300-1500 range for a while now. I am regularly doing contest and solving problem in range 1500-1700. I feel like I am not learning anything and my training is a waste. How should i train, so that I can learn fast as well as gain rating. Thank you guys.

Read more »

 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it