you can get the judge from here.
this is very tricky problem.
you can get the problem statement from here.
as we know
a&a = a so if we can observe that after k rounds, k elements from left and k elements from right are operated under boolean and operation with the ith element then it is easy to implement the code for it, an implement tweak is to generate three times of the sequence, and generate answer through that if
(2*k + 1) < n else and operation on all n elements.
one way to solve this problem is to make your own self balancing binary tree like AVL or RedBlack tree or with a little effort you can learn GNU policy based data structures available under GCC (available under all competitive programming platforms).
very nice problem on dp, here you shouldn’t spend time on the time where there isn’t any activity change.