#PS0000167. Đếm đoạn XOR K có độ dài chẵn (Count Even-Length Subarrays With XOR K)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đếm đoạn XOR K có độ dài chẵn (Count Even-Length Subarrays With XOR K)
Count Even-Length Subarrays With XOR K
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given an array of integers , numbered from 1. A nonempty contiguous interval contains all elements from through and has length . Count intervals whose bitwise XOR of all elements is equal to and whose length is even. Bitwise XOR has a 1 at a bit position exactly when an odd number of operands have a 1 there. Intervals with different endpoints are counted separately.
Input
The first line contains two integers . The second line contains integers .
Output
Print one integer: the number of qualifying intervals.
Subtasks
- Subtask 1 (30 points): ; for all ; .
- Subtask 2 (30 points): ; for all ; .
- Subtask 3 (40 points): ; for all ; .
Example 1
Input
3 0
1 1 1
Output
2
Explanation
The two intervals [1,2] and [2,3] have length 2 and XOR zero; no other even-length interval exists.
Example 2
Input
4 0
0 0 0 0
Output
4
Explanation
Three length-2 intervals and one length-4 interval all have XOR zero.