Contiguous Subsequence XOR
Time limit1sMemory limit512 MB
Count contiguous subsequences of the given sequence whose bitwise XOR is less than K.
- Level
Medium7 of 10
- Topics
- Bit manipulation, Trie, Prefix sum
- Solved
- No attempts yet
Problem
You are given a sequence of length . Count the contiguous subsequences whose XOR is less than .
A contiguous subsequence is for a pair of indices with . Its XOR is , where is the bitwise exclusive or.
Two contiguous subsequences with a different start position or a different end position count separately, even when their elements have the same values.
Input
The first line contains and , separated by a space. (, )
The second line contains in order, separated by spaces. ()
Output
Print the number of contiguous subsequences whose XOR is less than on the first line.