Блог пользователя Siraps

Автор Siraps, история, 3 года назад, По-английски

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?

Полный текст и комментарии »

  • Проголосовать: нравится
  • -4
  • Проголосовать: не нравится