A10247 | XOR and Favorite Number
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Bob has a favorite number $k$ and $a_{i}$ of length $n$ . Now he asks you to answer $m$ queries. Each query is given by a pair $l_{i}$ and $r_{i}$ and asks you to count the number of pairs of integers $i$ and $j$ , such that $l<=i<=j<=r$ and the xor of the numbers $a_{i},a_{i+1},...,a_{j}$ is equal to $k$ .
输入格式
The first line of the input contains integers $n$ , $m$ and $k$ ( $1<=n,m<=100000$ , $0<=k<=1000000$ ) — the length of the array, the number of queries and Bob's favorite number respectively.
The second line contains $n$ integers $a_{i}$ ( $0<=a_{i}<=1000000$ ) — Bob's array.
Then $m$ lines follow. The $i$ -th line contains integers $l_{i}$ and $r_{i}$ ( $1<=l_{i}<=r_{i}<=n$ ) — the parameters of the $i$ -th query.
The second line contains $n$ integers $a_{i}$ ( $0<=a_{i}<=1000000$ ) — Bob's array.
Then $m$ lines follow. The $i$ -th line contains integers $l_{i}$ and $r_{i}$ ( $1<=l_{i}<=r_{i}<=n$ ) — the parameters of the $i$ -th query.
输出格式
Print $m$ lines, answer the queries in the order they appear in the input.
输入输出样例
输入 #1
6 2 3 1 2 1 1 0 3 1 6 3 5
输出 #1
7 0
输入 #2
5 3 1 1 1 1 1 1 1 5 2 4 1 3
输出 #2
9 4 4
In the first sample the suitable pairs of $i$ and $j$ for the first query are: ( $1$ , $2$ ), ( $1$ , $4$ ), ( $1$ , $5$ ), ( $2$ , $3$ ), ( $3$ , $6$ ), ( $5$ , $6$ ), ( $6$ , $6$ ). Not a single of these pairs is suitable for the second query.
In the second sample xor equals $1$ for all subarrays of an odd length.
In the second sample xor equals $1$ for all subarrays of an odd length.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted