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. 1、Ansible安装配置

    ansible介绍: Ansible是一款基于Python开发的自动化运维工具,主要是实现批量系统配置.批量程序部署.批量运行命令.批量执行任务等等诸多功能.Ansible是一款灵活的开源工具,能够很 ...

  2. Tornado之笔记集合

    目录 一.基本使用 二.路由系统 三.视图函数 四.模版语言 五.cookie 六.CSRF 七.文件上传 八.异步非阻塞 九.RESTFUL 十.自定义组件 一.基本使用 1.最简使用 import ...

  3. Description Resource Path Location Type Cannot change version of project fac

    http://www.cnblogs.com/eaysun/p/5661631.html

  4. maven实战读书笔记(二)

    一个Spring加载属性的工具类,指定目标位置之后可以用${}的方式加载配置文件 测试maven工程发送email的例子:运行成功的例子—github 常用的命令: mvn clean compile ...

  5. TeamWork#3,Week5,Bing Input Method vs Sogou Input Method

    现在电脑上用五笔的用户越来越少了,好的拼音输入法也是难求.必应输入法的前身英库拼音输入法来自微软亚洲研究院的多项基础研究成果.最新的必应输入法不仅保留了英库拼音输入法的各项优势,还结合了必应的搜索体验 ...

  6. BETA-3

    前言 我们居然又冲刺了·三 团队代码管理github 站立会议 队名:PMS 530雨勤(组长) 过去两天完成了哪些任务 一堆deadline截至前的两天,为了图形学和编译原理毅然决然地放弃冲刺 接下 ...

  7. Java Head First & 多态

    package com.cwcec.tag; class Fruit { } class Apple extends Fruit{} class Animal { public Fruit eat(F ...

  8. Internet History, Technology and Security (Week 5-1)

    Week 5 Technology: Internets and Packets Welcome to Week 5! This week, we'll be covering internets a ...

  9. PAT 甲级 1154 Vertex Coloring

    https://pintia.cn/problem-sets/994805342720868352/problems/1071785301894295552 A proper vertex color ...

  10. Art & Material

    Art(Android runtime)模式伴随Android 4.4发布.相对于Dalvik模式来说,Art模式改善了Android程序的性能. Material Design伴随Android 5 ...