XOR

Consider an array AAA with n elements . Each of its element is A[i]A[i]A[i] (1≤i≤n)(1 \le i \le n)(1≤i≤n) . Then gives two integers QQQ, KKK, and QQQ queries follow . Each query , give you LLL, RRR, you can get ZZZ by the following rules.

To get ZZZ , at first you need to choose some elements from A[L]A[L]A[L] to A[R]A[R]A[R] ,we call them A[i1],A[i2]…A[it]A[i_1],A[i_2]…A[i_t]A[i1​],A[i2​]…A[it​] , Then you can get number Z=KZ = KZ=K or (A[i1]A[i_1]A[i1​] xor A[i2]A[i_2]A[i2​] … xor A[it]A[i_t]A[it​]) .

Please calculate the maximum ZZZ for each query .

Input

Several test cases .

First line an integer TTT (1≤T≤10)(1 \le T \le 10)(1≤T≤10) . Indicates the number of test cases.Then TTT test cases follows . Each test case begins with three integer NNN, QQQ, KKK (1≤N≤10000, 1≤Q≤100000, 0≤K≤100000)(1 \le N \le 10000,\ 1 \le Q \le 100000 , \ 0 \le K \le 100000)(1≤N≤10000, 1≤Q≤100000, 0≤K≤100000) . The next line has NNN integers indicate A[1]A[1]A[1] to A[N]A[N]A[N] (0≤A[i]≤108)(0 \le A[i] \le 10^8)(0≤A[i]≤108). Then QQQ lines , each line two integer LLL, RRR (1≤L≤R≤N)(1 \le L \le R \le N)(1≤L≤R≤N) .

Output

For each query , print the answer in a single line.

样例输入

1
5 3 0
1 2 3 4 5
1 3
2 4
3 5

样例输出

3
7
7
分析:线段树维护区间线性基;
   或一个数可以预处理的时候直接把有1的那些位屏蔽掉;
   现场做不出来,果然还是因为太菜了呢。。

2017icpc 西安 XOR的更多相关文章

  1. 计蒜客 A1607 UVALive 8512 [ACM-ICPC 2017 Asia Xi'an]XOR

    ICPC官网题面假的,要下载PDF,点了提交还找不到结果在哪看(我没找到),用VJ交还直接return 0;也能AC 计蒜客题面 这个好 Time limit 3000 ms OS Linux 题目来 ...

  2. CodeForces 1100F Ivan and Burgers

    CodeForces题面 Time limit 3000 ms Memory limit 262144 kB Source Codeforces Round #532 (Div. 2) Tags da ...

  3. 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 xor (根号分治)

    xor There is a tree with nn nodes. For each node, there is an integer value a_ia​i​​, (1 \le a_i \le ...

  4. 2017 ICPC网络赛(西安)--- Xor

    题目连接 Problem There is a tree with n nodes. For each node, there is an integer value ai, (1≤ai​≤1,000 ...

  5. 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 G. Xor

    There is a tree with nn nodes. For each node, there is an integer value a_ia​i​​, (1 \le a_i \le 1,0 ...

  6. 2017 ICPC西安区域赛 A - XOR (线段树并线性基)

    链接:https://nanti.jisuanke.com/t/A1607 题面:   Consider an array AA with n elements . Each of its eleme ...

  7. 【分块】计蒜客17120 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 G. Xor

    题意:给一棵树,每个点有权值.q次询问a,b,k,问你从a点到b点,每次跳距离k,权值的异或和? 预处理每个点往其根节点的路径上隔1~sqrt(n)的距离的异或和,然后把询问拆成a->lca(a ...

  8. ACM-ICPC 2017 西安赛区现场赛 A. XOR(线性基+线段树)

    题目链接:https://nanti.jisuanke.com/t/20749 参考题解:https://blog.csdn.net/Lee_w_j__/article/details/8266418 ...

  9. 【2017西安邀请赛:A】XOR(线段树+线性基)

    前言:虽然已经有很多题解了,但是还是想按自己的理解写一篇. 思路:首先分析题目 一.区间操作 —— 线段树 二.异或操作 —— 线性基 这个两个不难想,关键是下一步的技巧 “或”运算 就是两个数的二进 ...

随机推荐

  1. _bzoj1008 [HNOI2008]越狱【计数】

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1008 水题... #include <cstdio> const int mod ...

  2. Increasing Sequence CodeForces - 11A

    Increasing Sequence CodeForces - 11A 很简单的贪心.由于不能减少元素,只能增加,过程只能是从左到右一个个看过去,看到一个小于等于左边的数的数就把它加到比左边大,并记 ...

  3. 背包DP HDOJ 5410 CRB and His Birthday

    题目传送门 题意:有n个商店,有m金钱,一个商店买x件商品需要x*w[i]的金钱,得到a[i] * x + b[i]件商品(x > 0),问最多能买到多少件商品 01背包+完全背包:首先x == ...

  4. 转 php中$_request与$_post、$_get的区别

    php中有$_REQUEST与$_POST.$_GET用于接受表单数据,当时他们有何种区别,什么时候用那种最好. 一.$_REQUEST与$_POST.$_GET的区别和特点 $_REQUEST[]具 ...

  5. android开发学习——This support library should not use a different version

    http://blog.csdn.net/mvpstevenlin/article/details/55209966 完美解决系列

  6. Windows API函数大全一

    1. API之网络函数             WNetAddConnection 创建同一个网络资源的永久性连接             WNetAddConnection2 创建同一个网络资源的连 ...

  7. 【PostgreSQL-9.6.3】一般视图

    PG视图分为两种,一种是物化视图,一种是一般视图.本篇文章主要写一般视图哪些事儿.所谓一般视图,通俗点说,就是由查询语句定义的虚拟表.视图中的数据可能来自一张或多张表. 1. 视图创建语句 CREAT ...

  8. Node.js——body方式提交数据

    引入核心模块 http,利用其 api(http.createServer) 返回一个 http.server 实例,这个实例是继承于net.Server,net.Server 也是通过net.cre ...

  9. Zookeeper系列(一)

    一.ZooKeeper的背景 1.1 认识ZooKeeper ZooKeeper---译名为“动物园管理员”.动物园里当然有好多的动物,游客可以根据动物园提供的向导图到不同的场馆观赏各种类型的动物,而 ...

  10. python 求100以内所有素数

    def prime(num): for i in range(2, num): if num % i == 0: # 能被1之外的任意个数整除的即为非素数,返回False,将被filter函数过滤掉 ...