Bitwise OR
Practice
3.3 (9 votes)
String algorithms
Algorithms
String searching
Problem
85% Success 1200 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code
You are given an array $$A$$ of length $$N$$ and an integer $$X$$. You are required to find all the subarrays of minimum length with BITWISE OR greater than or equal to $$X$$.
Input format
- The first line of input contains an integer $$T$$ denoting the number of test cases.
- The first line of each test case contains $$N$$ and $$X$$.
- The second line of each test case contains $$N$$ space-separated integers each representing elements of array $$A$$.
Output format
For each test case:
In the first line, print count of such subarrays (let it be C). In the next C lines, print all the subarrays (in sorted order).
Note: A subarray can be defined by 2 indexes L and R where $$L$$ and $$R$$ are starting and ending indexes of that subarray)
Constraints
1 ≤ T ≤ 3
1 ≤ N ≤ 10^5
0 ≤ A[i] ≤ 10^9
0 ≤ X ≤ 1073741823
Submissions
Please login to view your submissions
Similar Problems
Points:30
9 votes
Tags:
String SearchingGreedy AlgorithmsAlgorithmsStringString Algorithms
2.Find Set
Points:30
3 votes
Tags:
AlgorithmsString SearchingString AlgorithmsC++
Points:30
8 votes
Tags:
String AlgorithmsAlgorithmsString Searching
Editorial