http://codeforces.com/contest/842/problem/D

树 二进制(路径,每个节点代表一位)

 #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <time.h>
#include <string>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <ext/rope>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define minv 1e-6
#define inf 1e9
#define pi 3.1415926536
#define E 2.7182818284
const ll mod=1e9+;//
const int maxn=1e5+; bool tr[<<]={};//19+2
int f[];
int w=; int main()
{
int n,m,a,b,i,j,k,value;
scanf("%d%d",&n,&m);
while (n--)
{
scanf("%d",&a);
b=a;
for (i=w;i>=;i--)
{ f[i]=a & ;
a>>=;
}
j=;
for (i=;i<=w;i++)
{
j<<=;
if (f[i]==)
j++;
}
tr[j]=;
} for (i=(<<w)-;i>=;i--)
tr[i]=tr[i<<]&tr[i<<|]; b=;
while (m--)
{
scanf("%d",&a);
b=a^b; a=b;
for (i=w;i>=;i--)
{
f[i]=a & ;
a>>=;
}
j=;
k=<<(w-);
value=;
for (i=;i<=w;i++)
{
j<<=;
if (!tr[j+f[i]])
{
j+=f[i];
}
else
{
j+=(f[i] ^ );
value+=k;
}
k>>=;
}
printf("%d\n",value);
}
return ;
}

D. Vitya and Strange Lesson Codeforces Round #430 (Div. 2)的更多相关文章

  1. Codeforces Round #430 (Div. 2) Vitya and Strange Lesson

    D.Vitya and Strange Lesson(字典树) 题意: 给一个长度为\(n\)的非负整数序列,\(m\)次操作,每次先全局异或\(x\),再查询\(mex\) \(1<=n< ...

  2. Codeforces Round #430 (Div. 2) 【A、B、C、D题】

    [感谢牛老板对D题的指点OTZ] codeforces 842 A. Kirill And The Game[暴力] 给定a的范围[l,r],b的范围[x,y],问是否存在a/b等于k.直接暴力判断即 ...

  3. 【Codeforces Round #430 (Div. 2) A C D三个题】

    ·不论难度,A,C,D自己都有收获! [A. Kirill And The Game] ·全是英文题,述大意:    给出两组区间端点:l,r,x,y和一个k.(都是正整数,保证区间不为空),询问是否 ...

  4. Codeforces Round #430 (Div. 2) D. Vitya and Strange Lesson

    因为抑或,一眼字典树 但是处理起来比较难 #include<iostream> #include<map> #include<iostream> #include& ...

  5. 【Codeforces Round #430 (Div. 2) D】Vitya and Strange Lesson

    [链接]点击打开链接 [题意] 给出一个数组,每次操作将整个数组亦或一个数x,问得到的数组的结果中的mex.mex表示为自然数中第一个没有出现过的数. [题解] 异或的效果是可以累加的,所以不用每次都 ...

  6. Vitya and Strange Lesson CodeForces - 842D 字典树+交换节点

    题意: Today at the lesson Vitya learned a very interesting function - mex. Mex of a sequence of number ...

  7. C - Ilya And The Tree Codeforces Round #430 (Div. 2)

    http://codeforces.com/contest/842/problem/C 树 dp 一个数的质因数有限,用set存储,去重 #include <cstdio> #includ ...

  8. Codeforces Round #430 (Div. 2) C. Ilya And The Tree

    地址:http://codeforces.com/contest/842/problem/C 题目: C. Ilya And The Tree time limit per test 2 second ...

  9. Codeforces Round #430 (Div. 2) - D

    题目链接:http://codeforces.com/contest/842/problem/D 题意:定义Mex为一个序列中最小的未出现的正整数,给定一个长度为n的序列,然后有m个询问,每个询问给定 ...

随机推荐

  1. 使用git-premit时的问题

    package.json 相关配置如下 { "scripts": { "lint": "eslint pages/* component/* --fi ...

  2. 机器学习:数据预处理之独热编码(One-Hot)

    前言 ———————————————————————————————————————— 在机器学习算法中,我们经常会遇到分类特征,例如:人的性别有男女,祖国有中国,美国,法国等.这些特征值并不是连续的 ...

  3. 软件工程-东北师大站-第十一次作业(PSP)

    PSP 饼状图 2.本周进度条 3.本周累计进度图 代码累计折线图 博文字数累计折线图  

  4. Notes of Daily Scrum Meeting(11.4)

    Notes of Daily Scrum Meeting 2014年11月4日  星期二  20:30—21:00 团队成员 今日团队任务 当日工作分配额 完成情况 陈少杰 阅读理解代码中底层与数据库 ...

  5. 2-Tenth Scrum Meeting20151210

    任务分配 闫昊: 今日完成:请假.(编译) 明日任务:参加会议讨论,安排任务分工. 唐彬: 今日完成:请假.(编译) 明日任务:参加会议讨论,安排任务分工. 史烨轩: 今日完成:请假.(编译) 明日任 ...

  6. Linux课程学习之我思

    陈民禾,原创作品转载请注明出处<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000,我的博客中有一部分是出自M ...

  7. EF三种编程方式详细图文教程(C#+EF)之Code First

    Code First Code First模式我们称之为“代码优先”模式,是从EF4.1开始新建加入的功能.使用Code First模式进行EF开发时开发人员只需要编写对应的数据类(其实就是领域模型的 ...

  8. 第二次作业<1>

    1001.A+B Format (20) ac代码 1. 解题思路 先求和,再输出. 答案区间为-2,000,000至2,000,000,将答案分为三个区段分类讨论.虽然觉得很烦但是想不出更好的方法. ...

  9. 3、第一个Python程序

    现在,了解了如何启动和退出Python的交互式环境,我们就可以正式开始编写Python代码了. 在写代码之前,请千万不要用“复制”-“粘贴”把代码从页面粘贴到你自己的电脑上.写程序也讲究一个感觉,你需 ...

  10. 数据库SQL中Like的用法总结

    最先做项目多次用到LIKE语句,下面总结下经常用到了. 语法 match_expression [ NOT ] LIKE pattern [ ESCAPE escape_character ] 参数 ...