Can anybody help why I am getting WA on test case 7?

https://codeforces.com/contest/339/submission/56760988

# Need Help on Xenia and Bit Operations (Codeforces)

I think you are getting WA because you are using parity of depth, you didn’t get any WA in earlier test cases because you are handling case n=1 separately.

To correct the solution try building the tree in bottom up manner

I am doing in bottom-up manner only no? Its segment tree. BTW test case passing for n=2 also.

i am saying your code is failing for n=1, or any odd n

and the depth variable you are using is the cause of failure. Try dry running for n=3

My test case is passing for case 3 (n=1). Please check. What is wrong with depth? Can you explain?

it is passing because of this part of your code

`if (n == 1) {

```
for (int i = 0; i < m; i++) {
int k, v;
scanf("%d", &k);
scanf("%d", &v);
a[k-1] = v;
printf("%d\n", a[0] | a[1]);
}
} `
```

like i said , it will fail for any other case when n is odd

import random

import math

import sys

def find_op(ar,n):

if n==2:

return ar[0]|ar[1]

else:

if (math.log(n,2)%2==0):

return find_op(ar[0:int(n/2)],n/2)^find_op(ar[int(n/2):n],n/2)

```
else:
return find_op(ar[0:int(n/2)],n/2)|find_op(ar[int(n/2):n],n/2)
```

l,q=input().strip(’ ‘).split(’ ‘)

ar=[int(x) for x in input().strip(’ ‘).split(’ ‘)]

q=int(q)

while (q>0):

pos,num=input().strip(’ ‘).split(’ ')

ar[int(pos)-1]=int(num)

print(find_op(ar,len(ar)))

q-=1

Showing runtime error for test case 7 … Can you please help me