Wrong answer on Codeforces EDU segment tree task. What is wrong with my code?

Правка en1, от Siraps, 2021-06-04 01:34:54

I am trying to solve E. Addition to Segment but for some reason I keep getting wrong answer on test case 3.You can see my code here. The weird thing is that when I change my set() function to the following:

void set(ll i, ll v, ll x, ll lx, ll rx)
	{
		if(i>=rx || i<lx) return;
		
		if(rx-lx==1)
		{
			values[x]+=v;
			return;
		}
		int m=(lx+rx)/2;
		set(i,v,2*x+1,lx,m);
		set(i,v,2*x+2,m,rx);
		values[x]=merge(values[2*x+1], values[2*x+2]);
		return;
	}

I get WA on testcase 63 (instead of testcase 3). This makes no sense to me because the two implementations of the set function should be logically equivalent. What is going on here?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Siraps 2021-06-04 01:34:54 941 Initial revision (published)