题中意思显而易见,即求满足al⊕al+1⊕…⊕amid=amid+1⊕amid+2⊕…⊕ar且l到r的区间长为偶数的这样的数对(l,r)的个数。

若al⊕al+1⊕…⊕amid=amid+1⊕amid+2⊕…⊕ar,我们可以推出al⊕al+1⊕…⊕amiamid+1⊕amid+2⊕…⊕ar=0;反推也是可以成立的。

我们已知任何数0对异或都等于本身。所以当前数异或一段数之后等于本身,那么异或之后的这段数肯定是异或为0的,我们只需要知道这一段是不是长度为偶数即可。

我们从头异或一道,若异或到某个数之后这个数在曾经出现过,我们就加上它可组成偶数段所有出现的次数即可。若全部异或为0,也是一种情况,我们假设0一开始也出现一次就好了。

用两个map统计奇偶(代码就能看懂)

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
map<ll,ll>p1;
map<ll,ll>p2;
ll a[];
int main()
{
ll n,t,k,i,j;
while(scanf("%I64d",&n)!=EOF)
{
k=;
p1.clear();
p2.clear();
scanf("%I64d",&j);
p2[j]=;
p1[]=;
for(i=;i<n;i++)
{
scanf("%I64d",&t);
j^=t;
if(i%==)
{
if(p2[j]!=)
k+=p2[j];
p2[j]++;
}
else
{ if(p1[j]!=)
k+=p1[j]; p1[j]++;
}
}
printf("%I64d\n",k);
}
}

Codeforces Round #539 (Div. 2) C Sasha and a Bit of Relax的更多相关文章

  1. Codeforces Round #539 (Div. 2) - C. Sasha and a Bit of Relax(思维题)

    Problem   Codeforces Round #539 (Div. 2) - C. Sasha and a Bit of Relax Time Limit: 2000 mSec Problem ...

  2. Codeforces Round #539 (Div. 2) C. Sasha and a Bit of Relax(前缀异或和)

    转载自:https://blog.csdn.net/Charles_Zaqdt/article/details/87522917 题目链接:https://codeforces.com/contest ...

  3. Codeforces Round #539 (Div. 2) - D. Sasha and One More Name(思维)

    Problem   Codeforces Round #539 (Div. 2) - D. Sasha and One More Name Time Limit: 1000 mSec Problem ...

  4. Codeforces Round #539 (Div. 1) C. Sasha and a Patient Friend 动态开点线段树

    题解看这里 liouzhou_101的博客园 更简洁的代码看这里: #include <bits/stdc++.h> using namespace std; typedef long l ...

  5. Codeforces Round #539 (Div. 1) E - Sasha and a Very Easy Test 线段树

    如果mod是质数就好做了,但是做除法的时候对于合数mod可能没有逆元.所以就只有存一下mod的每个质因数(最多9个)的幂,和剩下一坨与mod互质的一部分.然后就能做了.有点恶心. CODE #incl ...

  6. Codeforces Round #539 (Div. 1) 1109F. Sasha and Algorithm of Silence's Sounds LCT+线段树 (two pointers)

    题解请看 Felix-Lee的CSDN博客 写的很好,不过最后不用判断最小值是不是1,因为[i,i]只有一个点,一定满足条件,最小值一定是1. CODE 写完就A,刺激. #include <b ...

  7. Codeforces Round #539 (Div. 2)

    Codeforces Round #539 (Div. 2) A - Sasha and His Trip #include<bits/stdc++.h> #include<iost ...

  8. Codeforces Round #539 (Div. 2) 题解

    Codeforces Round #539 (Div. 2) 题目链接:https://codeforces.com/contest/1113 A. Sasha and His Trip 题意: n个 ...

  9. Codeforces Round #373 (Div. 2) E. Sasha and Array 线段树维护矩阵

    E. Sasha and Array 题目连接: http://codeforces.com/contest/719/problem/E Description Sasha has an array ...

随机推荐

  1. Why Everyone Should Lift Weights

    Why Everyone Should Lift Weights by James Clear I'll say it plain and simple: you should be lifting ...

  2. Linux 操作命令

    1. Linux 概述1.1. 内核版本    从技术角度来讲, Linux只是一个系统内核,一个内核并不是一套完整的操作系统.一套完整的操作系统应该包括内核. GNU应用程序库和工具.图形桌面环境等 ...

  3. XproerIM2-更新-2017-6-28

    资源下载:源代码,开发文档,客户端,openfire-3.9.3.exe,openfire-4.1.4.exe, 开源库:cximage600-full,boost-1.55.0,pugixml-1. ...

  4. IEEE/ACM International Conference on Advances in Social Network Analysis and Mining (ASONAM) 2014 Industry Track Call for Papers

    IEEE/ACM International Conference on Advances in Social Network Analysis and Mining (ASONAM) 2014 In ...

  5. APK签名说明

    在 Android 系统下, 一些公司会将自己做的APK进行管控,授权签名后方可使用. APK所属的软件公司会提供签名包,例如: 第一步:是要检查所操作的 PC 机是否安装 JDK,如果没有安装,请安 ...

  6. linux下Vim文本编辑器的常用快捷键

    Linux插入命令 a 在光标之后插入字符 A  把光标移动到行首尾进入插入模式 i 在光标之前插入字符 I 把光标移动到行首并进入插入模式 o 在光标下插入新行 O 在光标上插入新行 Linux定位 ...

  7. Java框架spring Boot学习笔记(十):传递数据到html页面的例子

    新建一个templates文件夹和index.html <!DOCTYPE html> <html> <head lang="en"> < ...

  8. .netframe初识

    转发自:https://blog.csdn.net/bingshan5haoao/article/details/32966581 https://www.cnblogs.com/liuxx/p/35 ...

  9. 【练习】Python第四次:实现对文件的增删改查

    一,实现对文件的增删改查 (一),三级菜单的处理结构及退出技巧:使用TAG标记 tag=True while tag: print('leve1') choice=input("level1 ...

  10. C#给checkboxList设置js选中事件

    C#: for (int i = 0; i < this.CheckBoxList1.Items.Count; i++)         {             this.CheckBoxL ...