values of positive integers. Pick three indices i < j ≤ k and cut the segment values[i..k] before position j into two non-empty parts:
- left: values[i] ^ ... ^ values[j - 1]
- right: values[j] ^ ... ^ values[k]
Here ^ is bitwise exclusive OR (XOR).
Return the number of triples (i, j, k) for which the XOR of the left part equals the XOR of the right part.values=[4, 4] → 1
The only triple is (0, 1, 1): [4] on the left, [4] on the right, both with XOR 4.
values=[1, 2, 3] → 2
1 ^ 2 ^ 3 = 0, so any cut of the segment [0, 2] works: (0, 1, 2) and (0, 2, 2). The answer is 2.
values=[6, 9, 15, 6, 6] → 9
values=[4, 4]
1
Run checks the first 3 tests in your browser. Submit checks all 80 tests on the server, hidden ones included.