can anybody explain how to solve this problem for 100 points?

…It’s not a live contest question.

thank you in advance!!

1 Like

You can check out my solution:

The short explanation of my solution is to have a dynamic segment tree for each possible value of x (only 0-255). Then for each value x in the array, add it to every segment tree that represents a value whose bit representation is a subset of the bit representation if x. Then for each query use inclusion exclusion on supersets of the desired value in bit representation.

I know this is a quick and dirty explanation. Feel free to ask follow up questions after reading the code.

@benjyamin , can you give the idea on how to solve that 'superior substring ’ question, was stuck on it for days, but never got more than 66 points after all the possible optimization((s)), can you explain the idea/solution ? :slight_smile:
Thanks in advance! :slight_smile:

Please explain how to solve the AND QUERY problem, and if possible make a editorial for it.
Link :