Bored Bakry solution codeforces

For Solution
Click Here!
Bakry got bored of solving problems related to xor, so he asked you to solve this problem for him.
You are given an array aa of nn integers [a1,a2,…,an][a1,a2,…,an].
Let’s call a subarray al,al+1,al+2,…,aral,al+1,al+2,…,ar good if al&al+1&al+2…&ar>al⊕al+1⊕al+2…⊕aral&al+1&al+2…&ar>al⊕al+1⊕al+2…⊕ar, where ⊕⊕ denotes the bitwise XOR operation and && denotes the bitwise AND operation.
Find the length of the longest good subarray of aa, or determine that no such subarray exists.
Bored Bakry solution codeforces
The first line contains a single integer nn (1≤n≤1061≤n≤106) — the length of the array.
The second line contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1061≤ai≤106) — elements of the array.
Print a single integer — the length of the longest good subarray. If there are no good subarrays, print 00.
input
Bored Bakry solution codeforces
2 5 6
output
2
Bored Bakry solution codeforces
3 2 4 3
output
0
input
6 8 1 3 3 1 2
output
4
Bored Bakry solution codeforces
In the first case, the answer is 22, as the whole array is good: 5&6=4>5⊕6=35&6=4>5⊕6=3.
In the third case, the answer is 44, and one of the longest good subarrays is [a2,a3,a4,a5][a2,a3,a4,a5]: 1&3&3&1=1>1⊕3⊕3⊕1=01&3&3&1=1>1⊕3⊕3⊕1=0.

For Solution
Click Here!