XORCOMP - Editorial

using namespace std; 



int main ()
{
 ios::sync_with_stdio(0);
            cin.tie(0);
        cout.tie(0);
long long t;
scanf("%lld",&t);
while(t--)
{


long long x,y,n;
//cin>>x>>y>>n;
scanf("%lld%lld%lld",&x,&y,&n);
long long c=0;
for(long long i=0; i<=n; i++)
 if((x^i)< (y^i) )
 c++;


 cout<<c<<'\n';

}


}
why this solution will give TLE is it O(n) time complexity  is not enough to pass all test case

In the question it is given N <= 2^30 and t <=100 so you would definitely get TLE. We need better than O(N) solution.

Here, N≤2^30−1. So, O(N) will give TLE ,beacuse in 1 second there passes approx 10^9 operations but in that soln , there are 2^20-1 operations at max which is very bigger than 10^9.

In other words, we are brute forcing all possible lengths of common suffixes between z and n.

hey bhagwan
sach me bachalere dev :")

1 Like

: } : } XD.

here y z[i] has to be 0?
cant the previous bits differ and make it smaller?
like most significant bit is 1 for both and preivous bits differ in a way so z<n

https://www.codechef.com/viewsolution/39937273

Can anyone tell me what’s wrong in this solution :weary:??

P.S. Subtask 1 failing. Idk why.

Can anyone please explain what if (a[j] > b[j]) i.e. to make the count possible we need z[j]=1
why are not considering it in 2nd Case ?

No bad words

This is general problem with Codechef. Authors don’t know how to determine difficulty of a problem.

Not simple, Try to help bro