CodeForces Round #647 div2

problem:
https://codeforces.com/contest/1362/problem/B
my solution which gives me the correct ans:
https://ideone.com/X0yVGC
in this above solution i use simple for loop to get the value of k.
But if i replace it with binary-search i am getting wrong output:
https://ideone.com/q0mqiO
Please can anyone tell what mistake am i making

Yeah, if check is false why are you changing l=mid+1?

Your binary search would work only if for a certain value of K and above the statement held always true. (The statement was minimum K for which xor of K and every element s would return the same elements at the end)

As far as I am aware the above claim is not true.

2 Likes

Let say if your check is giving 0. Then l=mid+1 according to your code. But how can you say that k will be in other half ? Also, your code is giving wrong output for sample TC

2 Likes