Bitwise OR
Practice
3.3 (9 votes)
String algorithms
Algorithms
String searching
Problem
85% Success 1202 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
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
5 votes
Tags:
AlgorithmsDynamic ProgrammingKMP AlgorithmMediumString Manipulation
Points:30
8 votes
Tags:
String AlgorithmsAlgorithmsString Searching
Points:20
47 votes
Tags:
ApprovedEasyMathOpen
Editorial
Login to unlock the editorial