A question that I am stuck in

Revision en1, by The_DarkKnight, 2021-12-19 09:53:32

I recently came across a question that reads as follows:

We are given n pairs of number: (a1,b1), (a2,b2)....(an,bn).

We need to find if there exists n numbers : x1,x2...xn such that a_i <= x_i <= b_i and (x1 & x2 & ....xn = 0) where & denotes bitwise and.

Constraints:

1<=n<=10^5

1<=a_i,b_i<=10^9

I thought of check for each bit if it becomes zero in each interval. But that is wrong as two bits can become zero in an interval but not necessarily at the same number.

How to proceed with this?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English The_DarkKnight 2021-12-19 09:53:32 552 Initial revision (published)