Maximum Bitwise OR by Window Length
Time limit2sMemory limit512 MB
For each window length K from 1 to N, output the maximum bitwise OR over all K consecutive elements of the array.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Divide and conquer, Array, Segment tree
- Solved
- No attempts yet
Problem
You are given an array of nonnegative integers. For every integer between and , find the largest value that the bitwise OR of consecutive elements of the array can take.
The bitwise OR of several nonnegative integers is the integer whose -th binary digit from the right is exactly when the -th binary digit from the right of every one of those integers is .
Input
The first line contains the length of the array ().
Each of the next lines contains one element of the array, an integer ().
Output
Print lines. On the -th line, print the largest value that the bitwise OR of consecutive elements of the array can take.