Approach please

Approach required. :slight_smile:
Any help would do…

Link to my code : github link

Can anybody help me to get an AC :frowning:

@l_returns @anon55659401

1 Like

I’ll check your code later…meanwhile…here is my short solution:—>
1)After some particular ‘k’, values will just keep repeating, you can that out by using the modulo operator,

2)For any, element, answer after ‘k’ rounds is :—> current element&(k-elements in left and k-elements in right), so do a range query for each element .

3)Make sure you make a cyclic segment tree, I mean this cyclic concept means just extending your array from size ‘n’ till it reaches ‘n-1’ again :slight_smile:

4)Example Problems(for cyclic stuff in array) :–> CIRMERGE Problem - CodeChef
Problem - B - Codeforces

if k > n then all elements become a[0]&a[1]&…a[n-1]
for other values of k implement a seg tree

If k>n/2… You may want to edit!!

agreed …

1 Like